Replace audio(9) get_props() with duplex check in open() in non-duplex drivers
authorkn <kn@openbsd.org>
Fri, 28 Oct 2022 15:09:45 +0000 (15:09 +0000)
committerkn <kn@openbsd.org>
Fri, 28 Oct 2022 15:09:45 +0000 (15:09 +0000)
commit7eff0e4e0f4f6052a2649fb49f86fac46f57cd50
tree4d458c8f3a241316e0e312b8923f5872e48c138b
parent925c301e87d2de7d3782bf136950a4be4334d3b7
Replace audio(9) get_props() with duplex check in open() in non-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.

These are all drivers which simply don't support full-duplex mode.

In device-tree based drivers like simpleaudio(4)/rkiis(4) and newer Apple
ones like aplaudio(4)/aplmca(4), this adds a new open() stub to the
low-level drivers which merely does the duplex check.

My Pinebook Pro keeps playing audio and recording silence with this diff
just like before (rkiis(4) is currently play-only):
simpleaudio0 at mainbus0
simpleaudio1 at mainbus0
audio0 at simpleaudio1

$ aucat -i song69.wav -o rec.wav

OK ratchov miod
sys/arch/arm64/dev/aplaudio.c
sys/arch/arm64/dev/aplmca.c
sys/arch/luna88k/cbus/nec86.c
sys/arch/luna88k/cbus/nec86hw.c
sys/arch/luna88k/cbus/nec86hwvar.h
sys/dev/fdt/graphaudio.c
sys/dev/fdt/rkiis.c
sys/dev/fdt/simpleaudio.c
sys/dev/ic/arcofi.c
sys/dev/pci/maestro.c