summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/audio-as3525.c
diff options
context:
space:
mode:
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