diff options
Diffstat (limited to 'firmware/target/arm/sandisk')
-rw-r--r-- | firmware/target/arm/sandisk/audio-c200_e200.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/firmware/target/arm/sandisk/audio-c200_e200.c b/firmware/target/arm/sandisk/audio-c200_e200.c index 1d78e71541..0037bac58b 100644 --- a/firmware/target/arm/sandisk/audio-c200_e200.c +++ b/firmware/target/arm/sandisk/audio-c200_e200.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "cpu.h" | 22 | #include "cpu.h" |
23 | #include "audio.h" | 23 | #include "audio.h" |
24 | #include "sound.h" | 24 | #include "sound.h" |
25 | #include "general.h" | ||
25 | 26 | ||
26 | int audio_channels = 2; | 27 | int audio_channels = 2; |
27 | int audio_output_source = AUDIO_SRC_PLAYBACK; | 28 | int audio_output_source = AUDIO_SRC_PLAYBACK; |
@@ -92,3 +93,85 @@ void audio_input_mux(int source, unsigned flags) | |||
92 | 93 | ||
93 | last_source = source; | 94 | last_source = source; |
94 | } /* audio_input_mux */ | 95 | } /* audio_input_mux */ |
96 | |||
97 | |||
98 | void audiohw_set_sampr_dividers(int fsel) | ||
99 | { | ||
100 | /* Seems to predivide 24MHz by 2 for a source clock of 12MHz. Maybe | ||
101 | * there's a way to set that? */ | ||
102 | static const struct | ||
103 | { | ||
104 | unsigned char iisclk; | ||
105 | unsigned char iisdiv; | ||
106 | } regvals[HW_NUM_FREQ] = | ||
107 | { | ||
108 | /* 8kHz - 24kHz work well but there seems to be a minor crackling | ||
109 | * issue for playback at times and all possibilities were checked | ||
110 | * for the divisors without any positive change. | ||
111 | * 32kHz - 48kHz seem fine all around. */ | ||
112 | #if 0 | ||
113 | [HW_FREQ_8] = /* CLK / 1500 (8000Hz) */ | ||
114 | { | ||
115 | .iisclk = 24, | ||
116 | .iisdiv = 59, | ||
117 | }, | ||
118 | [HW_FREQ_11] = /* CLK / 1088 (~11029.41Hz) */ | ||
119 | { | ||
120 | .iisclk = 33, | ||
121 | .iisdiv = 31, | ||
122 | }, | ||
123 | [HW_FREQ_12] = /* CLK / 1000 (120000Hz) */ | ||
124 | { | ||
125 | .iisclk = 49, | ||
126 | .iisdiv = 19, | ||
127 | }, | ||
128 | [HW_FREQ_16] = /* CLK / 750 (16000Hz) */ | ||
129 | { | ||
130 | .iisclk = 24, | ||
131 | .iisdiv = 29, | ||
132 | }, | ||
133 | [HW_FREQ_22] = /* CLK / 544 (~22058.82Hz) */ | ||
134 | { | ||
135 | .iisclk = 33, | ||
136 | .iisdiv = 15, | ||
137 | }, | ||
138 | [HW_FREQ_24] = /* CLK / 500 (24000Hz) */ | ||
139 | { | ||
140 | .iisclk = 49, | ||
141 | .iisdiv = 9, | ||
142 | }, | ||
143 | #endif | ||
144 | [HW_FREQ_32] = /* CLK / 375 (32000Hz) */ | ||
145 | { | ||
146 | .iisclk = 24, | ||
147 | .iisdiv = 14, | ||
148 | }, | ||
149 | [HW_FREQ_44] = /* CLK / 272 (~44117.68Hz) */ | ||
150 | { | ||
151 | .iisclk = 33, | ||
152 | .iisdiv = 7, | ||
153 | }, | ||
154 | [HW_FREQ_48] = /* CLK / 250 (48000Hz) */ | ||
155 | { | ||
156 | .iisclk = 49, | ||
157 | .iisdiv = 4, | ||
158 | }, | ||
159 | /* going a bit higher would be nice to get 64kHz play, 32kHz rec, but a | ||
160 | * close enough division isn't obtainable unless CLK can be changed */ | ||
161 | }; | ||
162 | |||
163 | IISCLK = (IISCLK & ~0x17ff) | regvals[fsel].iisclk; | ||
164 | IISDIV = (IISDIV & ~0xc000003f) | regvals[fsel].iisdiv; | ||
165 | } | ||
166 | |||
167 | unsigned int pcm_sampr_type_rec_to_play(unsigned int samplerate) | ||
168 | { | ||
169 | /* Check if the samplerate is in the list of recordable rates. | ||
170 | * Fail to default if not */ | ||
171 | int index = round_value_to_list32(samplerate, rec_freq_sampr, | ||
172 | REC_NUM_FREQ, false); | ||
173 | if (samplerate != rec_freq_sampr[index]) | ||
174 | return HW_SAMPR_DEFAULT; | ||
175 | |||
176 | return samplerate * 2; /* Recording rates are 1/2 the codec clock */ | ||
177 | } | ||