summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2014-05-30 00:26:27 +0200
committerSzymon Dziok <b0hoon@o2.pl>2014-06-01 23:25:12 +0200
commit53efa59e12f2de50bdb54e4a590c680063c39e1c (patch)
tree6c90855111fa00bd553891c3dd63b9240b4f5de4 /firmware/drivers
parent5237b36a858819378618e0d034d4b89c0bea1617 (diff)
downloadrockbox-53efa59e12f2de50bdb54e4a590c680063c39e1c.tar.gz
rockbox-53efa59e12f2de50bdb54e4a590c680063c39e1c.zip
recording on Samsung YH-820/YH-92x
Change-Id: I6eac4cf6c16a322910ad17bfbf3105e330cd0e36 Reviewed-on: http://gerrit.rockbox.org/815 Reviewed-by: Szymon Dziok <b0hoon@o2.pl> Tested: Szymon Dziok <b0hoon@o2.pl>
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/audio/ak4537.c104
1 files changed, 99 insertions, 5 deletions
diff --git a/firmware/drivers/audio/ak4537.c b/firmware/drivers/audio/ak4537.c
index 90d264e445..799bf83946 100644
--- a/firmware/drivers/audio/ak4537.c
+++ b/firmware/drivers/audio/ak4537.c
@@ -223,22 +223,116 @@ void audiohw_set_frequency(int fsel)
223#if defined(HAVE_RECORDING) 223#if defined(HAVE_RECORDING)
224void audiohw_enable_recording(bool source_mic) 224void audiohw_enable_recording(bool source_mic)
225{ 225{
226 (void)source_mic; 226 if (source_mic)
227 {
228 /* enable mic power supply */
229#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
230 /* additionally select external mic */
231 akc_set(AK4537_MIC, MPWRE | MSEL);
232#else
233 akc_set(AK4537_MIC, MPWRI);
234#endif
235
236 /* mic out is connected to line1 input */
237 akc_clear(AK4537_PM3, INL | INR);
238
239 /* route ALC output to ADC input */
240 akc_set(AK4537_MIC, MICAD);
241 /* set ALC (automatic level control) to manual mode */
242 akc_clear(AK4537_ALC1, ALC1);
243 /* set gain control to 'dependent' (left&right at the same time) */
244 akc_clear(AK4537_MIC, IPGAC);
245 /* power up mic preamp, left channel ADC and line in */
246 akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL);
247 /* power up right channel ADC and line in */
248 akc_set(AK4537_PM3, PMADR | PMIPGR);
249 }
250 else
251 {
252 /* disable mic power supply */
253#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
254 akc_clear(AK4537_MIC, MPWRE);
255#else
256 akc_clear(AK4537_MIC, MPWRI);
257#endif
258 /* disable mic preamp */
259 akc_clear(AK4537_PM1, PMMICL);
260
261 /* Select line1 input */
262 akc_clear(AK4537_PM3, INL | INR);
263 /* route ALC output to ADC input */
264 akc_set(AK4537_MIC, MICAD);
265 /* set ALC (automatic level control) to manual mode */
266 akc_clear(AK4537_ALC1, ALC1);
267
268 /* set gain control to independent left & right gain */
269 akc_set(AK4537_MIC, IPGAC);
270
271 /* power up left channel input and ADC */
272 akc_set(AK4537_PM1, PMADL | PMIPGL);
273 /* power up right channel input and ADC */
274 akc_set(AK4537_PM3, PMADR | PMIPGR);
275 }
227} 276}
228 277
229void audiohw_disable_recording(void) 278void audiohw_disable_recording(void)
230{ 279{
280 /* disable mic power supply */
281#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
282 akc_clear(AK4537_MIC, MPWRE);
283#else
284 akc_clear(AK4537_MIC, MPWRI);
285#endif
286 /* power down ADC, mic preamp and line amp */
287 akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL);
288 akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR);
231} 289}
232 290
233void audiohw_set_recvol(int left, int right, int type) 291void audiohw_set_recvol(int left, int right, int type)
234{ 292{
235 (void)left; 293 switch (type)
236 (void)right; 294 {
237 (void)type; 295 case AUDIO_GAIN_MIC:
296 /* the mic preamp has a fixed gain of +15 dB. There's an additional
297 * activatable +20dB mic gain stage. The signal is then routed to
298 * the Line1 input, where you find the line attenuator with a range
299 * from -23.5 to +12dB, so we have a total gain range of -8.0 .. +47dB.
300 * NOTE: the datasheet state's different attenuator levels for mic and
301 * line input, but that's not precise. The +15dB difference result only
302 * from the mic stage.
303 * NOTE2: the mic is connected to the line1 input (via mic preamp),
304 * so if a line signal is present, you will always record a mixup.
305 */
306 /* If gain is > 20 dB we use the additional gain stage */
307 if (left > 20) {
308 akc_set(AK4537_MIC, MGAIN);
309 left -= 20;
310 }
311 else {
312 akc_clear(AK4537_MIC, MGAIN);
313 }
314 /* the remains is done by the line input amp */
315 left = (left+8)*2;
316 akc_write(AK4537_IPGAL, left);
317 break;
318 case AUDIO_GAIN_LINEIN:
319 /* convert dB to register value */
320 left = (left+23)*2+1;
321 right = (right+23)*2+1;
322 akc_write(AK4537_IPGAL, left);
323 akc_write(AK4537_IPGAR, right);
324 break;
325 default:
326 return;
327 }
238} 328}
239 329
240void audiohw_set_monitor(bool enable) 330void audiohw_set_monitor(bool enable)
241{ 331{
242 (void)enable; 332 if (enable)
333 /* mix input signal to headphone output */
334 akc_set(AK4537_SIGSEL2, MICL);
335 else
336 akc_clear(AK4537_SIGSEL2, MICL);
243} 337}
244#endif /* HAVE_RECORDING */ 338#endif /* HAVE_RECORDING */