Select the types of activity you want to include in your feed.
pcm: introduce pcm_sink
move target-specific pcm operations into builtin_pcm_sink. in subsequent commits, another pcm_sink is added, and it becomes possible to switch between them.
···2727#include "pcm.h"
2828#include "pcm_sampr.h"
2929#include "pcm-internal.h"
3030+#include "pcm_sink.h"
30313132/** DMA **/
3233···8990 .state = 0
9091};
91929292-void pcm_dma_apply_settings(void)
9393-{
9494- audiohw_set_frequency(pcm_fsel);
9595-}
9393+/* DMA status cannot be viewed from outside code in control because that can
9494+ * clear the interrupt from outside the handler and prevent the handler from
9595+ * from being called. Split up transfers to a reasonable size that is good as
9696+ * a timer and peaking yet still keeps the FIQ count low.
9797+ */
9898+static uint16_t max_dma_chunk_size;
969997100#if defined(CPU_PP502x)
98101/* 16-bit, L-R packed into 32 bits with left in the least significant halfword */
···102105#define DMA_PLAY_CONFIG ((DMA_REQ_IIS << DMA_CMD_REQ_ID_POS) | \
103106 DMA_CMD_RAM_TO_PER | DMA_CMD_SINGLE | \
104107 DMA_CMD_WAIT_REQ | DMA_CMD_INTR)
105105-/* DMA status cannot be viewed from outside code in control because that can
106106- * clear the interrupt from outside the handler and prevent the handler from
107107- * from being called. Split up transfers to a reasonable size that is good as
108108- * a timer and peaking yet still keeps the FIQ count low.
109109- */
110110-#define MAX_DMA_CHUNK_SIZE (pcm_curr_sampr >> 6) /* ~1/256 seconds */
111108112109static inline void dma_tx_init(void)
113110{
···145142146143static inline void dma_tx_start(bool begin)
147144{
148148- size_t size = MAX_DMA_CHUNK_SIZE;
145145+ size_t size = max_dma_chunk_size;
149146150150- /* Not at least MAX_DMA_CHUNK_SIZE left or there would be less
147147+ /* Not at least max_dma_chunk_size left or there would be less
151148 * than a FIFO's worth of data after this transfer? */
152149 if (size + 16*4 > dma_play_data.size)
153150 size = dma_play_data.size;
···430427#endif /* ASM / C selection */
431428#endif /* CPU_PP502x */
432429430430+static void sink_set_freq(uint16_t freq) {
431431+ max_dma_chunk_size = hw_freq_sampr[freq] >> 6;
432432+ audiohw_set_frequency(freq);
433433+}
434434+433435/* For the locks, FIQ must be disabled because the handler manipulates
434436 IISCONFIG and the operation is not atomic - dual core support
435437 will require other measures */
436436-void pcm_play_lock(void)
438438+static void sink_lock(void)
437439{
438440 int status = disable_fiq_save();
439441···444446 restore_fiq(status);
445447}
446448447447-void pcm_play_unlock(void)
449449+static void sink_unlock(void)
448450{
449451 int status = disable_fiq_save();
450452···455457 restore_fiq(status);
456458}
457459458458-static void play_start_pcm(void)
460460+static void sink_start_pcm(void)
459461{
460462 fiq_function = fiq_playback;
461463 dma_play_data.state = 1;
462464 dma_tx_start(true);
463465}
464466465465-static void play_stop_pcm(void)
467467+static void sink_stop_pcm(void)
466468{
467469 dma_tx_stop();
468470···472474 dma_play_data.state = 0;
473475}
474476475475-void pcm_play_dma_start(const void *addr, size_t size)
477477+static void sink_dma_stop(void);
478478+479479+static void sink_dma_start(const void *addr, size_t size)
476480{
477477- pcm_play_dma_stop();
481481+ sink_dma_stop();
478482479483#if NUM_CORES > 1
480484 /* This will become more important later - and different ! */
···485489486490 dma_play_data.addr = dma_tx_buf_prepare(addr);
487491 dma_play_data.size = size;
488488- play_start_pcm();
492492+ sink_start_pcm();
489493}
490494491495/* Stops the DMA transfer and interrupt */
492492-void pcm_play_dma_stop(void)
496496+static void sink_dma_stop(void)
493497{
494494- play_stop_pcm();
498498+ sink_stop_pcm();
495499 dma_play_data.addr = 0;
496500 dma_play_data.size = 0;
497501#if NUM_CORES > 1
···499503#endif
500504}
501505502502-void pcm_play_dma_init(void)
506506+static void sink_dma_init(void)
503507{
504508 /* Initialize default register values. */
505509 audiohw_init();
···509513 IISCONFIG |= IIS_TXFIFOEN;
510514}
511515512512-void pcm_play_dma_postinit(void)
513513-{
514514- audiohw_postinit();
515515-}
516516+struct pcm_sink builtin_pcm_sink = {
517517+ .caps = {
518518+ .samprs = hw_freq_sampr,
519519+ .num_samprs = HW_NUM_FREQ,
520520+ .default_freq = HW_FREQ_DEFAULT,
521521+ },
522522+ .ops = {
523523+ .init = sink_dma_init,
524524+ .postinit = audiohw_postinit,
525525+ .set_freq = sink_set_freq,
526526+ .lock = sink_lock,
527527+ .unlock = sink_unlock,
528528+ .play = sink_dma_start,
529529+ .stop = sink_dma_stop,
530530+ },
531531+};
516532517533/****************************************************************************
518534 ** Recording DMA transfer