summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/audio-as3525.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-12-08 19:20:00 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-12-08 19:20:00 +0000
commite42a3194de3b4fb9cd3e7cbd2e0ff17fea804b72 (patch)
tree71ddb9c8a927ac4b4a2ba962cd92f935eb1ba445 /firmware/target/arm/as3525/audio-as3525.c
parent2c7379757cb20ac9731c98847c6f6309d32607f3 (diff)
downloadrockbox-e42a3194de3b4fb9cd3e7cbd2e0ff17fea804b72.tar.gz
rockbox-e42a3194de3b4fb9cd3e7cbd2e0ff17fea804b72.zip
AS3525v1/v2:
Fix problems with volume of recorded material by converting 14-bit samples to 16-bit. Remove duplicate samples from recorded data and support proper samplerate since ADC runs 1/2 the codec clock. Support monitoring mono on both output channels by feeding data manually to I2SOUT under the right conditions. DMA is no longer used for recording since frames must be processed as described above but it does allow full-duplex audio. Miscellaneous change includes a proper constant (HW_SAMPR_DEFAULT) to reset the hardware samplerate when recording is closed. PP5024 and AS3525 have different default recording rates (22kHz and 44kHz respectively) but both have half-speed ADC. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31180 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/audio-as3525.c')
-rw-r--r--firmware/target/arm/as3525/audio-as3525.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c
index 10c6161881..e4bb39b406 100644
--- a/firmware/target/arm/as3525/audio-as3525.c
+++ b/firmware/target/arm/as3525/audio-as3525.c
@@ -24,16 +24,33 @@
24#include "audio.h" 24#include "audio.h"
25#include "audiohw.h" 25#include "audiohw.h"
26#include "sound.h" 26#include "sound.h"
27#include "general.h"
27 28
28int audio_channels = 2; 29int audio_channels = 2;
29 30
31#if CONFIG_CPU == AS3525
32int audio_output_source = AUDIO_SRC_PLAYBACK;
33#endif
34
30void audio_set_output_source(int source) 35void audio_set_output_source(int source)
31{ 36{
32 bitset32(&CGU_PERI, CGU_I2SOUT_APB_CLOCK_ENABLE); 37 bitset32(&CGU_PERI, CGU_I2SOUT_APB_CLOCK_ENABLE);
33 if (source == AUDIO_SRC_PLAYBACK) 38
34 I2SOUT_CONTROL &= ~(1<<5); 39 if ((unsigned)source >= AUDIO_NUM_SOURCES)
40 source = AUDIO_SRC_PLAYBACK;
41
42 bool loopback = source != AUDIO_SRC_PLAYBACK;
43
44#if CONFIG_CPU == AS3525
45 loopback = loopback && audio_channels > 1;
46
47 audio_output_source = source;
48#endif
49
50 if (loopback)
51 I2SOUT_CONTROL |= (1<<5); /* loopback from i2sin fifo */
35 else 52 else
36 I2SOUT_CONTROL |= 1<<5; /* source = loopback from i2sin fifo */ 53 I2SOUT_CONTROL &= ~(1<<5); /* normal i2sout */
37} 54}
38 55
39void audio_input_mux(int source, unsigned flags) 56void audio_input_mux(int source, unsigned flags)
@@ -108,4 +125,33 @@ void audio_input_mux(int source, unsigned flags)
108 } 125 }
109 126
110 last_source = source; 127 last_source = source;
128
129#if CONFIG_CPU == AS3525
130 /* Sync on behalf of change in number of channels */
131 audio_set_output_source(audio_output_source);
132#endif
111} 133}
134
135#ifdef CONFIG_SAMPR_TYPES
136unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate,
137 unsigned int type)
138{
139#ifdef HAVE_RECORDING
140 if (samplerate != HW_SAMPR_RESET && type == SAMPR_TYPE_REC)
141 {
142 /* Check if the samplerate is in the list of recordable rates.
143 * Fail to default if not */
144 int index = round_value_to_list32(samplerate, rec_freq_sampr,
145 REC_NUM_FREQ, false);
146 if (samplerate != rec_freq_sampr[index])
147 samplerate = REC_SAMPR_DEFAULT;
148
149 samplerate *= 2; /* Recording rates are 1/2 the codec clock */
150 }
151#endif /* HAVE_RECORDING */
152
153 return samplerate;
154 (void)type;
155}
156#endif /* CONFIG_SAMPR_TYPES */
157