diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-10-06 22:27:27 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-10-06 22:27:27 +0000 |
commit | 6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2 (patch) | |
tree | a6bc91ee4168e83617e942eeaea46e5523e82420 /firmware/target/arm/pnx0101/pcm-pnx0101.c | |
parent | f6de0d4083a4fcb6da57f271e1f8ccaf715e571d (diff) | |
download | rockbox-6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2.tar.gz rockbox-6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2.zip |
Unify PCM interface just above the hardware driver level for all targets including the sims. Perform lockout of audio callback when changing states. Weird new playback or recording trouble? Check before and after this revision first though things seem quite sound.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15006 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/pnx0101/pcm-pnx0101.c')
-rw-r--r-- | firmware/target/arm/pnx0101/pcm-pnx0101.c | 69 |
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 @@ | |||
25 | short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES]; | 25 | short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES]; |
26 | short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES]; | 26 | short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES]; |
27 | 27 | ||
28 | /* From pcm_playback.c */ | 28 | static int pcm_freq = HW_SAMPR_DEFAULT; /* 44.1 is default */ |
29 | extern unsigned short* p; | 29 | |
30 | extern size_t p_size; | 30 | unsigned short* p IBSS_ATTR; |
31 | size_t p_size IBSS_ATTR; | ||
32 | |||
33 | void pcm_play_lock(void) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | void pcm_play_unlock(void) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | void 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 | |||
49 | void pcm_play_dma_stop(void) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | void pcm_play_dma_pause(bool pause) | ||
54 | { | ||
55 | if (!pause) | ||
56 | pcm_apply_settings(); | ||
57 | } | ||
31 | 58 | ||
32 | static inline void fill_dma_buf(int offset) | 59 | static 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 | ||
188 | void pcm_postinit(void) | ||
189 | { | ||
190 | audiohw_postinit(); | ||
191 | pcm_apply_settings(); | ||
192 | } | ||
193 | |||
194 | void pcm_set_frequency(unsigned int frequency) | ||
195 | { | ||
196 | (void)frequency; | ||
197 | pcm_freq = HW_SAMPR_DEFAULT; | ||
198 | } | ||
199 | |||
200 | void pcm_apply_settings(void) | ||
201 | { | ||
202 | pcm_curr_sampr = pcm_freq; | ||
203 | } | ||
204 | |||
205 | size_t pcm_get_bytes_waiting(void) | ||
206 | { | ||
207 | return p_size & ~3; | ||
208 | } | ||
209 | |||
210 | const 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 | } | ||