Home | History | Annotate | Download | only in iomd
History log of /src/sys/arch/arm/iomd/vidcaudio.c
RevisionDateAuthorComments
 1.62  27-Sep-2022  skrll malloc -> kmem
 1.61  03-Feb-2021  isaki Remove a comment no longer correct.
Because halt_output is no longer called from an interrupt context,
but that does not mean it's better to put this back to halt_output.
 1.60  23-Feb-2020  isaki branches: 1.60.6;
Make start_input/halt_input optional if the driver has no recording,
make start_output/halt_output optional if the driver has no playback.
And remove such never called functions.
 1.59  08-Jun-2019  isaki branches: 1.59.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.58  08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.57  16-Mar-2019  isaki branches: 1.57.2;
Use C99 style struct initializer to audio_hw_if.
 1.56  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.55  13-Dec-2016  christos branches: 1.55.14; 1.55.16;
back to passing device_t
 1.54  09-Dec-2016  christos audiobell now only needs the unit.
 1.53  25-Oct-2014  skrll branches: 1.53.2; 1.53.4;
Remove katelib.h and references to it.

{Read,Write}{Word,Byte} macros are provided in the files that still use
them. Someone(tm) should convert them to bus_space(9)
 1.52  13-Sep-2014  matt Replace more vm_offset_t, vm_size_t with vaddr_t, vsize_t
Use paddr_t for msgbufphys
 1.51  10-Oct-2012  skrll Use device_xname.

From chuq.
 1.50  14-May-2012  skrll branches: 1.50.2;
device_t/softc split
struct device * -> device_t
struct cfdata * -> cfdata_t
Use aprint*
 1.49  10-May-2012  skrll KNF
 1.48  24-Nov-2011  mrg branches: 1.48.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.47  23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.46  01-Mar-2008  chris branches: 1.46.38; 1.46.40;
Fix acorn32 console beep to actually beep, rather than the kernel say:
aurateconv_fetch_to: internal error: unsupported encoding: enc=1 prec=8

The issue was that the playback filters for audio were being added to the
list in the wrong order. The first entry in the list is closest to the
hardware, the last is closest to the audio buffer. The code thought it
the other way around, so the incorrect formats were being passed down the
filter list.
 1.45  22-Feb-2007  thorpej branches: 1.45.2; 1.45.22; 1.45.24; 1.45.40; 1.45.44;
TRUE -> true, FALSE -> false
 1.44  14-Aug-2006  bjh21 branches: 1.44.8;
Finally remove the old, pre-wscons, acorn32 console code. This dated back
to RiscBSD and had been lurking in dark corners scaring people (mostly me)
for far too long. It will be missed, but not much, and I hope we can clear
up any fallout before 5.0.

While I'm in the area, also remove rpckbd(4), since pckbd(4) has
been supported on acorn32 for ages.
 1.43  11-Dec-2005  christos branches: 1.43.4; 1.43.8;
merge ktrace-lwp.
 1.42  15-Jan-2005  kent branches: 1.42.10;
ansify and KNF
 1.41  10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.40  29-Oct-2004  yamt branches: 1.40.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.39  13-Mar-2004  bjh21 Add support for using the MI pckbd and pms drivers with the IOMD keyboard
and mouse ports, with a new driver, iomdkbc(4).
 1.38  25-Jan-2004  bjh21 Remove spurious inclusion of obsolete <arch/arm/iomd/waveform.h>.
 1.37  18-Jan-2004  bjh21 vidcaudio_set_params() must return a value (oops!).
 1.36  17-Jan-2004  bjh21 Change the control flow in vidcaudio_set_params() so as to make the indentation
less hairy.
 1.35  17-Jan-2004  bjh21 Adjust vt(4) (WHICH MUST DIE) to the new way of handling bells on
NetBSD/acorn32.
 1.34  17-Jan-2004  bjh21 Use audiobell for system beeps on acorn32 when vidcaudio(4) is compiled in.
Remove the vestigal sysbeep device and replace it with the same kind of
mechanism that pckbd(4) uses to find the bell, which is just as ugly, but
more standard. Adapt beep(4) to the new world (though I'm not sure it
deserves to live).
 1.33  10-Jan-2004  bjh21 The VIDC20 data sheet doesn't define the polarity of the sign bit for
8-bit VIDC audio. Both Richard Earnshaw and I had guessed that a set
bit was positive (the same as normal mu-law), but the AudioWorks
manual, and Sound_SoundLog on RISC OS, seem to disagree. Change
MULAW_TO_VIDC to match Sound_SoundLog, since the latter is probably
definitive.
 1.32  03-Jan-2004  chris Currently the eb7500atx doesn't have a cmos_read function, however it also
won't use the RPC600_IOMD_ID code path, so disable that code path for the
eb7500atx.
 1.31  01-Jan-2004  bjh21 No need to #include "vidcaudio.h" here, so don't do it.
 1.30  01-Jan-2004  bjh21 Rather than calling pmap_extract() from an IPL_AUDIO interrupt handler (which
is naughty even if it does work), find out the complete list of physical pages
we'll have to DMA from in vidcaudio_trigger_output() and save it for use by
the interrupt handler.
 1.29  01-Jan-2004  bjh21 Restore a call to vidcaudio_ctrl() that I accidentally deleted.
 1.28  01-Jan-2004  bjh21 Tidy up debugging printfs to use a single #ifdef and a DPRINTF() macro,
rather than #ifdefs scattered all over the code.
 1.27  01-Jan-2004  bjh21 Add possibly-useful support for 16-bit sound on VIDC20 systems, using
RISC OS's "*Configure SoundSystem" setting to decide whether to use 16-bit
mode. Loosely based on parts of Richard Earnshaw's "sound16" patch.
 1.26  31-Dec-2003  bjh21 When returning our actual sample rate to audio(4) in 16-bit mode, use the right
base clock rate.
 1.25  31-Dec-2003  bjh21 Make local functions static.
 1.24  31-Dec-2003  bjh21 Substantial rewrite of vidcaudio(4). I don't know if the old version
had ever worked, but if it had, it had bit-rotted so far that it
almost all needed replacing. The new version support both 8-bit sound
on the VIDC20 and 16-bit sound on the ARM7500 and ARM7500FE.
sysbeep() support has been lost, but I'm not sure whether that belongs
here or in audio(4) anyway. Support for 16-bit sound on the VIDC20
isn't present because I don't have the hardware to test it. Donations
welcome!
 1.23  29-Dec-2003  bjh21 speaker_ctl() is optional, and vidcaudio_speaker_ctl() did nothing, so kill it.
 1.22  29-Dec-2003  bjh21 Control debugging with VIDCAUDIO_DEBUG rather that DEBUG, to avoid confusion
with the global kernel macro called DEBUG.
 1.21  29-Dec-2003  bjh21 Minor KNF.
 1.20  29-Dec-2003  bjh21 Fix a DEBUG printf.
 1.19  29-Dec-2003  bjh21 Use NULL rather than 0 to initialise unused function pointers.
 1.18  29-Dec-2003  bjh21 KNF.
 1.17  29-Dec-2003  bjh21 ANSIfy, un-__P().
 1.16  06-Dec-2003  bjh21 Don't complain if we're asked for != 8 channels. There's no actual support
for fewer channels yet, but this is necessary just to avoid a boot-time panic.
 1.15  26-Oct-2003  jdolecek fix NULL vs. 0 usage
 1.14  01-Apr-2003  thorpej branches: 1.14.2;
Use PAGE_SIZE rather than NBPG.
 1.13  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL
 1.12  01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.11  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10  27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.9  16-Jun-2002  bjh21 struct vidcaudio_softc.iobase was unused other than to initialise it. G/C it.
This also means that the "aux" parameter to vidcaudio_attach is unused.
 1.8  10-Apr-2002  thorpej branches: 1.8.2;
vm_offset_t -> vaddr_t,paddr_t
 1.7  05-Apr-2002  thorpej * Rewrite the 32-bit ARM pte.h based on the ARM architecture manual.
Significant cleanup, here, including better PTE bit names.
* Add XScale PTE extensions (ECC enable, write-allocate cache mode).
* Mechanical changes everywhere else to update for new pte.h. While
doing this, two bugs (as a result of typos) were fixed in

arm/arm32/bus_dma.c
evbarm/integrator/int_bus_dma.c
 1.6  10-Mar-2002  bjh21 __RCSID -> __KERNEL_RCSID
 1.5  18-Feb-2002  bjh21 Add prototypes to all declarations of function pointers.
Include <arch/arm/iomd/vidcaudiovar.h> for vidcaudio_beep_generate() prototype.
Add in-core RCSID.
 1.4  27-Nov-2001  thorpej branches: 1.4.2;
Use <machine/intr.h> rather than <machine/irqhandler.h>
 1.3  22-Nov-2001  thorpej Kill <machine/katelib.h>. Any place that still uses it should just
reference <arm/arm32/katelib.h> until such time as all use of this
file has been purged from the face of the earth.
 1.2  17-Oct-2001  reinoud branches: 1.2.4;
Sad point .... remove RC7500 support from the iomd directory in the
arch/arm/iomd/* .... the RC7500 isnt really an iomd/vidc machine but has
different video/audio chip and was kind of hardwired/hacked into the other
chip drivers.
 1.1  05-Oct-2001  reinoud Initial commit of the splitting off of arch/acorn32 from arch/arm32.

The IOMD/VIDC combination is now moved to arch/arm/iomd together. These
files still need a lot of cleaning up :( .... esp. the RC7500 support that
is still dormant in it; this needs either to be removed or split out for
RC7500's ``VIDC'' video/audio variant.

Apart from the RC7500 support wich is still in arch/arm32 the
iomd,vidc,riscpc and podulebus subdirectories of arch/arm32 can be removed.

This split still uses some small parts of arch/arm32 .... those are the MI
parts that haven't been moved yet.

RiscPC/A7000 have been tested and confirmed to build as should NC.
 1.2.4.7  18-Oct-2002  nathanw Catch up to -current.
 1.2.4.6  20-Jun-2002  nathanw Catch up to -current.
 1.2.4.5  17-Apr-2002  nathanw Catch up to -current.
 1.2.4.4  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.3  28-Feb-2002  nathanw Catch up to -current.
 1.2.4.2  08-Jan-2002  nathanw Catch up to -current.
 1.2.4.1  17-Oct-2001  nathanw file vidcaudio.c was added on branch nathanw_sa on 2002-01-08 00:23:16 +0000
 1.4.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.3  16-Mar-2002  jdolecek Catch up with -current.
 1.4.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1  27-Nov-2001  thorpej file vidcaudio.c was added on branch kqueue on 2002-01-10 19:38:21 +0000
 1.8.2.1  14-Jul-2002  gehenna catch up with -current.
 1.14.2.5  17-Jan-2005  skrll Sync with HEAD.
 1.14.2.4  02-Nov-2004  skrll Sync with HEAD.
 1.14.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1  03-Aug-2004  skrll Sync with HEAD
 1.40.2.3  09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.40.2.2  05-Jan-2005  kent introduce FILTER_LOOP_PROLOGUE() and FILTER_LOOP_EPILOGUE() macros, and
simplify filter implementations by the macros.
 1.40.2.1  03-Jan-2005  kent adopt the filter pipeline framework
 1.42.10.3  17-Mar-2008  yamt sync with head.
 1.42.10.2  26-Feb-2007  yamt sync with head.
 1.42.10.1  30-Dec-2006  yamt sync with head.
 1.43.8.1  03-Sep-2006  yamt sync with head.
 1.43.4.1  09-Sep-2006  rpaulo sync with head
 1.44.8.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.45.44.1  03-Apr-2008  mjf Sync with HEAD.
 1.45.40.1  24-Mar-2008  keiichi sync with head.
 1.45.24.1  23-Mar-2008  matt sync with HEAD
 1.45.22.2  21-Mar-2008  chris Sync with head.
 1.45.22.1  09-Feb-2008  chris Add initial reworking of acorn32 to use new interrupt code.

Note that cats probably won't work currently as acorn32 changed the way
that the pic is registered, it has to provide the irq lines as on acorn32
we attach the iomd after we need to register irqs for the pioc. So we
setup the irqs for iomd before malloc etc are available. This needs
to be fixed.

More work is still needed to update most of the podulebus drivers.
First I need to add podulebus wrapper for interrupts that handles the
maskaddr and maskbits. Exposing them to the common irq code is wrong.
 1.45.2.1  27-Feb-2007  ad Add MP locking for audio drivers.
 1.46.40.2  22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.46.40.1  20-Nov-2011  mrg port to audiomp: get_locks support, stream filter updates, remove IPL_AUDIO

not run time tested.
 1.46.38.3  30-Oct-2012  yamt sync with head
 1.46.38.2  23-May-2012  yamt sync with head.
 1.46.38.1  17-Apr-2012  yamt sync with head
 1.48.2.1  02-Jun-2012  mrg sync to latest -current.
 1.50.2.2  03-Dec-2017  jdolecek update from HEAD
 1.50.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.53.4.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.53.2.1  05-Feb-2017  skrll Sync with HEAD
 1.55.16.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.55.16.1  10-Jun-2019  christos Sync with HEAD
 1.55.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.57.2.3  04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.57.2.2  04-May-2019  isaki Move dev/audiobell* -> dev/audio/audiobell*.
 1.57.2.1  21-Apr-2019  isaki Adapt to audio2.
 1.59.4.1  29-Feb-2020  ad Sync with head.
 1.60.6.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed