Commit Graph

8 Commits

Author SHA1 Message Date
Jeff Epler 742aa740f6 samd: audio: Move to background callback
Testing performed: Played half of the Bartlebeats album :) :)
2020-07-15 09:26:47 -05:00
jepler 30a9346373 samd: audio_dma: Track channel allocation
Previously, we depended on allocated channels to always be
"dma_channel_enabled".  However, (A) sometimes, many operations
would take place between find_free_audio_dma_channel and
audio_dma_enable_channel, and (B) some debugging I did led me to believe
that "dma_channel_enabled" would become false when the hardware ended
a scheduled DMA transaction, but while a CP object would still think it
owned the DMA channel.

((B) is not documented in the datasheet and I am not 100% convinced that
my debugging session was not simply missing where we were disabling the
channel, but in either case, it shows a need to directly track allocated
separately from enabled)

Therefore,
 * Add audio_dma_{allocate,free}_channel.
   * audio_dma_free_channel implies audio_dma_disable_channel
   * track via a new array audio_dma_allocated[]
 * clear all allocated flags on soft-reboot
 * Convert find_free_audio_dma_channel to audio_dma_allocate_channel
   * use audio_dma_allocated[] instead of dma_channel_enabled() to check
     availability
 * remove find_free_audio_dma_channel
 * For each one, find a matching audio_dma_disable_channel to convert
   to audio_dma_free_channel

Closes: #2058
2019-08-28 17:00:22 -05:00
Jeff Epler 8b717955ba samd: audio_dma: wrap dma_{en,dis}able_channel and add error checking
It turns out the "disable" error will fire in practice, we'll fix that
next.
2019-08-06 22:00:31 -05:00
Jeff Epler 6b44e40ee8 audiocore: Factor from audioio
When nrf pwm audio is introduced, it will be called `audiopwmio`.  To
enable code sharing with the existing (dac-based) `audioio`, factor
the sample and mixer types to `audiocore`.

INCOMPATIBLE CHANGE: Now, `Mixer`, `RawSample` and `WaveFile` must
be imported from `audiocore`, not `audioio`.
2019-07-25 06:44:26 -05:00
Dan Halbert e2e01efa84 compiles and runs; hangs on import storage;storage.VfsFat.<tab> 2018-07-13 22:51:10 -04:00
Scott Shawcroft 50fc90bc5f Add pause/resume control to AudioOut and I2SOut
Fixes #808
2018-05-08 11:53:13 -07:00
Scott Shawcroft cfea51ec68 Re-enable PDMIn without ASF and using the helpers added with
I2SOut.

The API is almost the same except the frequency attribute has been
renamed to sample_rate so that its less likely to be confused with
frequencies within the audio itself.

Fixes #263.
2018-05-01 14:35:43 -07:00
Scott Shawcroft 28642ab10d Add audio output support!
This evolves the API from 2.x (and breaks it). Playback devices are now
separate from the samples themselves. This allows for greater playback
flexibility. Two sample sources are audioio.RawSample and audioio.WaveFile.
They can both be mono or stereo. They can be output to audioio.AudioOut or
audiobusio.I2SOut.

Internally, the dma tracking has changed from a TC counting block transfers
to an interrupt generated by the block event sent to the EVSYS. This reduces
the overhead of each DMA transfer so multiple can occure without using up TCs.

Fixes #652. Fixes #522. Huge progress on #263
2018-04-12 16:35:13 -07:00