summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pnx0101/pcm-pnx0101.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pnx0101/pcm-pnx0101.c')
-rw-r--r--firmware/target/arm/pnx0101/pcm-pnx0101.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/firmware/target/arm/pnx0101/pcm-pnx0101.c b/firmware/target/arm/pnx0101/pcm-pnx0101.c
index 8b076cc918..adfc752e8e 100644
--- a/firmware/target/arm/pnx0101/pcm-pnx0101.c
+++ b/firmware/target/arm/pnx0101/pcm-pnx0101.c
@@ -25,9 +25,36 @@
25short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES]; 25short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES];
26short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES]; 26short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES];
27 27
28/* From pcm_playback.c */ 28static int pcm_freq = HW_SAMPR_DEFAULT; /* 44.1 is default */
29extern unsigned short* p; 29
30extern size_t p_size; 30unsigned short* p IBSS_ATTR;
31size_t p_size IBSS_ATTR;
32
33void pcm_play_lock(void)
34{
35}
36
37void pcm_play_unlock(void)
38{
39}
40
41void pcm_play_dma_start(const void *addr, size_t size)
42{
43 pcm_apply_settings();
44
45 p = (unsigned short*)addr;
46 p_size = size;
47}
48
49void pcm_play_dma_stop(void)
50{
51}
52
53void pcm_play_dma_pause(bool pause)
54{
55 if (!pause)
56 pcm_apply_settings();
57}
31 58
32static inline void fill_dma_buf(int offset) 59static inline void fill_dma_buf(int offset)
33{ 60{
@@ -85,7 +112,8 @@ static inline void fill_dma_buf(int offset)
85 &p_size); 112 &p_size);
86 } 113 }
87 while (p_size); 114 while (p_size);
88 pcm_playing = false; 115
116 pcm_play_dma_stopped_callback();
89 } 117 }
90 118
91 if (l < lend) 119 if (l < lend)
@@ -117,9 +145,7 @@ void pcm_init(void)
117{ 145{
118 int i; 146 int i;
119 147
120 pcm_playing = false; 148 pcm_set_frequency(HW_SAMPR_DEFAULT);
121 pcm_paused = false;
122 pcm_callback_for_more = NULL;
123 149
124 memset(dma_buf_left, 0, sizeof(dma_buf_left)); 150 memset(dma_buf_left, 0, sizeof(dma_buf_left));
125 memset(dma_buf_right, 0, sizeof(dma_buf_right)); 151 memset(dma_buf_right, 0, sizeof(dma_buf_right));
@@ -159,3 +185,32 @@ void pcm_init(void)
159 DMAR10(1) |= 1; 185 DMAR10(1) |= 1;
160} 186}
161 187
188void pcm_postinit(void)
189{
190 audiohw_postinit();
191 pcm_apply_settings();
192}
193
194void pcm_set_frequency(unsigned int frequency)
195{
196 (void)frequency;
197 pcm_freq = HW_SAMPR_DEFAULT;
198}
199
200void pcm_apply_settings(void)
201{
202 pcm_curr_sampr = pcm_freq;
203}
204
205size_t pcm_get_bytes_waiting(void)
206{
207 return p_size & ~3;
208}
209
210const void * pcm_play_dma_get_peak_buffer(int *count)
211{
212 unsigned long addr = (unsigned long)p;
213 size_t cnt = p_size;
214 *count = cnt >> 2;
215 return (void *)((addr + 2) & ~3);
216}