From 34c4cc1bd95f50e299e6091f9bbaa2e7e01097b7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 23 Apr 2021 09:46:33 -0500 Subject: [PATCH] samd: Rename dma_{allocate,free} channel These are now used in the (video) parallel capture device as well. --- ports/atmel-samd/audio_dma.c | 8 ++++---- ports/atmel-samd/audio_dma.h | 4 ++-- ports/atmel-samd/common-hal/audiobusio/PDMIn.c | 4 ++-- .../common-hal/imagecapture/ParallelImageCapture.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c index b18db9c67a..7b1ca42c06 100644 --- a/ports/atmel-samd/audio_dma.c +++ b/ports/atmel-samd/audio_dma.c @@ -53,7 +53,7 @@ uint8_t find_sync_event_channel_raise() { return event_channel; } -uint8_t audio_dma_allocate_channel(void) { +uint8_t dma_allocate_channel(void) { uint8_t channel; for (channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) { if (!audio_dma_allocated[channel]) { @@ -64,7 +64,7 @@ uint8_t audio_dma_allocate_channel(void) { return channel; // i.e., return failure } -void audio_dma_free_channel(uint8_t channel) { +void dma_free_channel(uint8_t channel) { assert(channel < AUDIO_DMA_CHANNEL_COUNT); assert(audio_dma_allocated[channel]); audio_dma_disable_channel(channel); @@ -188,7 +188,7 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma, bool output_signed, uint32_t output_register_address, uint8_t dma_trigger_source) { - uint8_t dma_channel = audio_dma_allocate_channel(); + uint8_t dma_channel = dma_allocate_channel(); if (dma_channel >= AUDIO_DMA_CHANNEL_COUNT) { return AUDIO_DMA_DMA_BUSY; } @@ -306,7 +306,7 @@ void audio_dma_stop(audio_dma_t *dma) { disable_event_channel(dma->event_channel); MP_STATE_PORT(playing_audio)[channel] = NULL; audio_dma_state[channel] = NULL; - audio_dma_free_channel(dma->dma_channel); + dma_free_channel(dma->dma_channel); } dma->dma_channel = AUDIO_DMA_CHANNEL_COUNT; } diff --git a/ports/atmel-samd/audio_dma.h b/ports/atmel-samd/audio_dma.h index d6c766efb8..4e7d193b1d 100644 --- a/ports/atmel-samd/audio_dma.h +++ b/ports/atmel-samd/audio_dma.h @@ -66,8 +66,8 @@ uint8_t audiosample_channel_count(mp_obj_t sample_obj); void audio_dma_init(audio_dma_t *dma); void audio_dma_reset(void); -uint8_t audio_dma_allocate_channel(void); -void audio_dma_free_channel(uint8_t channel); +uint8_t dma_allocate_channel(void); +void dma_free_channel(uint8_t channel); // This sets everything up but doesn't start the timer. // Sample is the python object for the sample to play. diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index cbb50bec83..6ea70e39dc 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -367,7 +367,7 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) { // output_buffer_length is the number of slots, not the number of bytes. uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self, uint16_t* output_buffer, uint32_t output_buffer_length) { - uint8_t dma_channel = audio_dma_allocate_channel(); + uint8_t dma_channel = dma_allocate_channel(); uint8_t event_channel = find_sync_event_channel_raise(); // We allocate two buffers on the stack to use for double buffering. @@ -473,7 +473,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se } disable_event_channel(event_channel); - audio_dma_free_channel(dma_channel); + dma_free_channel(dma_channel); // Turn off serializer, but leave clock on, to avoid mic startup delay. i2s_set_serializer_enable(self->serializer, false); diff --git a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c index d596796135..074c2b6d23 100644 --- a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c @@ -157,7 +157,7 @@ static void setup_dma(DmacDescriptor* descriptor, size_t count, uint32_t *buffer void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { - uint8_t dma_channel = audio_dma_allocate_channel(); + uint8_t dma_channel = dma_allocate_channel(); uint32_t *dest = buffer; size_t count = bufsize / 4; // PCC receives 4 bytes (2 pixels) at a time @@ -178,7 +178,7 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli RUN_BACKGROUND_TASKS; // Allow user to break out of a timeout with a KeyboardInterrupt. if (mp_hal_is_interrupted()) { - audio_dma_free_channel(dma_channel); + dma_free_channel(dma_channel); return; } } @@ -194,5 +194,5 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli } dma_disable_channel(dma_channel); - audio_dma_free_channel(dma_channel); + dma_free_channel(dma_channel); }