History log of /openbsd-current/sys/arch/hppa/gsc/harmony.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.41 22-May-2024 jsg

remove prototypes with no matching function; ok miod@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.40 26-Oct-2022 kn

Make audio(9) get_props() optional, remove it from duplex drivers

The property bits of audio(9) are obsolete and ought to be removed
completely.

sys/dev/audio.c:audio_open() currently uses get_props() to bail out if
read *and* write was requested on a non-duplex driver.

Drivers that currently support playing but not recording need adjustment
before the API can be cleaned up.

Drivers that advertise themselves as full duplex, i.e. those that always
return AUDIO_PROP_FULLDUPLEX unconditionally in their get_props() currently
always succeed this check.

As this is the only property, losen audio_open()'s DIAGNOSTIC check and only
do the duplex check if the driver provides get_props().

This allows for simple removal of get_props() from full-duplex drivers
without adding any other code or without changing functionality.

This includes all audio drivers under sys/dev/pci/ (maestro(4) being the
only unfinished exception here).

Other drivers as well as the API change can then follow in smaller diffs.

This builds on amd64, arm64, i386, macppc and sparc64.
amd64 with azalia(4) still plays, records as well as plays and records
at the same time on my X230 as tested with

$ aucat -i play.wav [-o rec.wav]

alpha and hppa tests by miod
OK ratchov miod


# 1.39 19-Oct-2022 kn

Use C99 struct init for struct audio_hw_if

This audio(9) struct will lose a member, but drivers init their struct quite
inconsistently, most pre-C99 style.

Use C99 style everywhere, to get rid of all annoying differences and allow
for easy member removals/additions:
- don't change current order of members
- no explicit NULL members
- no comments or blank lines
- trailing comma in last member line

GENERIC.MP builds fine with this on arm64, amd64, i386 and sparc64.

macppc and alpha build-tested by miod
OK ratchov miod


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.38 21-Mar-2022 miod

Constify struct {audio,midi,radio,video}_hw_if. No functional change.

ok mpi@ ratchov@ "More const is good" deraadt@


# 1.37 13-Mar-2022 mpi

Constify struct cfattach.

ok miod@


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.40 26-Oct-2022 kn

Make audio(9) get_props() optional, remove it from duplex drivers

The property bits of audio(9) are obsolete and ought to be removed
completely.

sys/dev/audio.c:audio_open() currently uses get_props() to bail out if
read *and* write was requested on a non-duplex driver.

Drivers that currently support playing but not recording need adjustment
before the API can be cleaned up.

Drivers that advertise themselves as full duplex, i.e. those that always
return AUDIO_PROP_FULLDUPLEX unconditionally in their get_props() currently
always succeed this check.

As this is the only property, losen audio_open()'s DIAGNOSTIC check and only
do the duplex check if the driver provides get_props().

This allows for simple removal of get_props() from full-duplex drivers
without adding any other code or without changing functionality.

This includes all audio drivers under sys/dev/pci/ (maestro(4) being the
only unfinished exception here).

Other drivers as well as the API change can then follow in smaller diffs.

This builds on amd64, arm64, i386, macppc and sparc64.
amd64 with azalia(4) still plays, records as well as plays and records
at the same time on my X230 as tested with

$ aucat -i play.wav [-o rec.wav]

alpha and hppa tests by miod
OK ratchov miod


# 1.39 19-Oct-2022 kn

Use C99 struct init for struct audio_hw_if

This audio(9) struct will lose a member, but drivers init their struct quite
inconsistently, most pre-C99 style.

Use C99 style everywhere, to get rid of all annoying differences and allow
for easy member removals/additions:
- don't change current order of members
- no explicit NULL members
- no comments or blank lines
- trailing comma in last member line

GENERIC.MP builds fine with this on arm64, amd64, i386 and sparc64.

macppc and alpha build-tested by miod
OK ratchov miod


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.38 21-Mar-2022 miod

Constify struct {audio,midi,radio,video}_hw_if. No functional change.

ok mpi@ ratchov@ "More const is good" deraadt@


# 1.37 13-Mar-2022 mpi

Constify struct cfattach.

ok miod@


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.39 19-Oct-2022 kn

Use C99 struct init for struct audio_hw_if

This audio(9) struct will lose a member, but drivers init their struct quite
inconsistently, most pre-C99 style.

Use C99 style everywhere, to get rid of all annoying differences and allow
for easy member removals/additions:
- don't change current order of members
- no explicit NULL members
- no comments or blank lines
- trailing comma in last member line

GENERIC.MP builds fine with this on arm64, amd64, i386 and sparc64.

macppc and alpha build-tested by miod
OK ratchov miod


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.38 21-Mar-2022 miod

Constify struct {audio,midi,radio,video}_hw_if. No functional change.

ok mpi@ ratchov@ "More const is good" deraadt@


# 1.37 13-Mar-2022 mpi

Constify struct cfattach.

ok miod@


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.38 21-Mar-2022 miod

Constify struct {audio,midi,radio,video}_hw_if. No functional change.

ok mpi@ ratchov@ "More const is good" deraadt@


# 1.37 13-Mar-2022 mpi

Constify struct cfattach.

ok miod@


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.37 13-Mar-2022 mpi

Constify struct cfattach.

ok miod@


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.36 16-Feb-2022 anton

Make room for a cookie argument passed to audio_attach_mi(). Currently
unused but intended to be used to correlate audio and wskbd devices.

ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


# 1.34 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.33 19-Sep-2016 ratchov

Remove unused getdev() audio driver functions.


# 1.32 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_9_BASE OPENBSD_6_0_BASE
# 1.31 08-Sep-2015 deraadt

sizes for free(), when known; ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.30 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@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.29 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 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.27 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


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 21-Apr-2008 jakemsr

allow low level audio drivers to specify a default sample format,
instead of 8-bit mono mulaw @ 8kHz.

this is just the infrastructure; no drivers are specifying a default
yet.

ok ratchov@, deanna@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 20-May-2006 mickey

do not even match on unsupported hw (instead of return from attach); from 710


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.24 16-Apr-2005 mickey

round -- not truncate the buffer size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 13-Feb-2004 mickey

order irq,pri args to gsc_intr_establish() the way less confusing compared to other trolley busses around ...


# 1.22 20-Dec-2003 miod

Pass -Wformat, fix a few uninitialized variables as well.


Revision tags: OPENBSD_3_4_BASE
# 1.21 15-Aug-2003 mickey

bitneaks anonymous randomisation


# 1.20 07-Aug-2003 mickey

make all intr_establish take the same last arg for name


# 1.19 02-Jun-2003 jason

nuke clause 3 & 4


Revision tags: UBC_SYNC_A
# 1.18 11-May-2003 deraadt

string cleaning; krw ok


Revision tags: OPENBSD_3_3_BASE
# 1.17 12-Mar-2003 mickey

branches: 1.17.4;
reclaim more resources on failures.
test the harmony id to filter out unsupported yet
audio types and detect the teleshare.
detect input overload and report to userland.


# 1.16 05-Feb-2003 jason

Add knob for getting at the "output level bit", supposedly changes the
full scale outputs between 2.8Vpp and 2.0Vpp for line.


# 1.15 05-Feb-2003 jason

Get rid of the pops:
- interrupt is called when the block has been DMA'd... since LASI seems to
include a FIFO this is -not- the same as block completion which we have
to poll for. Luckily the FIFO is deep enough that polling in the
interrupt handler seems to work.
- This probably breaks capture, but I'll fix that when I get up tomorrow.
(committed to the tune of Fugazi's "Waiting Room")


# 1.14 30-Jan-2003 mickey

reread the dma status reg after playing part of the dma got programmed.
according to the doc, the "play next" bit and therefore the device
interrupt may get raised earlier than the "record next" is set,
thus we might not program the record dma and get another harmony
interrupt right after servicing this one. this little optimization
allows to deal w/ the situation more efficiently, should it occur.
jason@ ok


# 1.13 30-Jan-2003 mickey

real meat in audio_device; discussed w/ jason@


# 1.12 30-Jan-2003 jason

Check the codec revision... if it's >=CS4215E or >=AD1849K (same value
strangely =) the make ulinear (native) and slinear (emulated) available.
Also, while here, make ulinear_le:16 available via emulation.
(Btw, the LASI docs say that the format code for ulinear is a
reserved value... Probably just wasn't available in the early CS4215/AD1849's)


# 1.11 29-Jan-2003 mickey

print out the codec revision in dmesg


# 1.10 28-Jan-2003 jason

Ok, you can only set the HE/SE/LE/IS bits in GAINCTL when reset is asserted (why? I have no clue, but not abding this causes the chip to wedge).
So, you can now switch input/output ports to your hearts content...
oh did I mention several commits ago that capture works?


# 1.9 28-Jan-2003 jason

Move device driver specific stuff to *var.h and add most of the code for
dealing with output source selection (doesn't work right yet, so its disabled).


# 1.8 27-Jan-2003 jason

Stupid stupid stupid... DMA will not start until the capture next register
is written. I'm not sure how to -correctly- handle this for the fullduplex
case, but this seems to make playback sound MUCH better...


# 1.7 27-Jan-2003 jason

As promised, I got some sleep and rewrote most of the driver... playback
is still a bit spotty, but at least interrupts are not enabled constantly
any more.
Also discovered a feature: messing with the LINE/MIC bit in GAINCTL has
the side effect of wedging the chip under some circumstances, but I think
this can be worked around by resetting the codec... later.


# 1.6 27-Jan-2003 jason

separate register defns and revise them based on the LASI info... a HUGE
chunk of this driver will be rewritten once I've gotten some zzz's.


# 1.5 27-Jan-2003 jason

I declare defeat... once interrupts are enabled, just leave them enabled.
This is annoying because the chip will keep dma'n, but everytime I disable
interrupts in halt_*, they never come back. Grr.


# 1.4 27-Jan-2003 jason

Write to the cntl register with the c flag set.


# 1.3 26-Jan-2003 jason

Ok, playback more or less works, now for capture. (I forgot to save the pintr/parg)


# 1.2 26-Jan-2003 jason

Ok, this now produces some noise (that's the best way I can describe it),
but the timing appears to get off some how and buffers just stay on the
chip. Oh well, at least its keeping me from playing in the traffic.


# 1.1 26-Jan-2003 jason

Start on the harmony audio driver. It doesn't play or capture anything
yet, but the knobs and interrupt routine seem to work. More to come.