diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2009-02-05 19:57:18 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2009-02-05 19:57:18 +0000 |
commit | ea7f1430960cc6ccc16f67fe43c95d2341033642 (patch) | |
tree | 68843470bb257523cda24d8ddf09ed088aea872f | |
parent | d8662489dc19592abccca44c0e1254584c6a0d29 (diff) | |
download | rockbox-ea7f1430960cc6ccc16f67fe43c95d2341033642.tar.gz rockbox-ea7f1430960cc6ccc16f67fe43c95d2341033642.zip |
FS#9611 - Sansa Clip radio code. Commit final part which enables the LINE2 input that carries the analog radio signal on ams sansas.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19927 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/audio/as3514.c | 76 | ||||
-rw-r--r-- | firmware/export/as3514.h | 2 | ||||
-rw-r--r-- | firmware/export/audiohw.h | 7 | ||||
-rw-r--r-- | firmware/target/arm/as3525/audio-as3525.c | 43 |
4 files changed, 95 insertions, 33 deletions
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 23d1c52b56..dc6efb511a 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c | |||
@@ -31,6 +31,14 @@ | |||
31 | #include "i2s.h" | 31 | #include "i2s.h" |
32 | #include "ascodec.h" | 32 | #include "ascodec.h" |
33 | 33 | ||
34 | /* AMS Sansas based on the AS3525 use the LINE2 input for the analog radio | ||
35 | signal instead of LINE1 */ | ||
36 | #if CONFIG_CPU == AS3525 | ||
37 | #define LINE_INPUT 2 | ||
38 | #else | ||
39 | #define LINE_INPUT 1 | ||
40 | #endif | ||
41 | |||
34 | const struct sound_settings_info audiohw_settings[] = { | 42 | const struct sound_settings_info audiohw_settings[] = { |
35 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | 43 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, |
36 | /* HAVE_SW_TONE_CONTROLS */ | 44 | /* HAVE_SW_TONE_CONTROLS */ |
@@ -227,9 +235,13 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
227 | 235 | ||
228 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); | 236 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); |
229 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); | 237 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); |
230 | #ifdef HAVE_RECORDING | 238 | #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) |
231 | as3514_write_masked(AS3514_LINE_IN1_R, mix_r, AS3514_VOL_MASK); | 239 | as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_R : |
232 | as3514_write_masked(AS3514_LINE_IN1_L, mix_l, AS3514_VOL_MASK); | 240 | AS3514_LINE_IN2_R, |
241 | mix_r, AS3514_VOL_MASK); | ||
242 | as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_L : | ||
243 | AS3514_LINE_IN2_L, | ||
244 | mix_l, AS3514_VOL_MASK); | ||
233 | #endif | 245 | #endif |
234 | as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK); | 246 | as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK); |
235 | as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK); | 247 | as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK); |
@@ -237,10 +249,8 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
237 | 249 | ||
238 | void audiohw_set_lineout_vol(int vol_l, int vol_r) | 250 | void audiohw_set_lineout_vol(int vol_l, int vol_r) |
239 | { | 251 | { |
240 | as3514_write_masked(AS3514_LINE_OUT_R, vol_r, | 252 | as3514_write_masked(AS3514_LINE_OUT_R, vol_r, AS3514_VOL_MASK); |
241 | AS3514_VOL_MASK); | 253 | as3514_write_masked(AS3514_LINE_OUT_L, vol_l, AS3514_VOL_MASK); |
242 | as3514_write_masked(AS3514_LINE_OUT_L, vol_l, | ||
243 | AS3514_VOL_MASK); | ||
244 | } | 254 | } |
245 | 255 | ||
246 | void audiohw_mute(bool mute) | 256 | void audiohw_mute(bool mute) |
@@ -286,19 +296,24 @@ void audiohw_enable_recording(bool source_mic) | |||
286 | as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_ST_MIC, | 296 | as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_ST_MIC, |
287 | ADC_R_ADCMUX); | 297 | ADC_R_ADCMUX); |
288 | 298 | ||
289 | /* MIC1_on, LIN1_off */ | 299 | /* MIC1_on, others off */ |
290 | as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on, | 300 | as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on, |
291 | AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); | 301 | AUDIOSET1_INPUT_MASK); |
302 | |||
292 | /* M1_AGC_off */ | 303 | /* M1_AGC_off */ |
293 | as3514_clear(AS3514_MIC1_R, MIC1_R_M1_AGC_off); | 304 | as3514_clear(AS3514_MIC1_R, MIC1_R_M1_AGC_off); |
294 | } else { | 305 | } else { |
295 | /* ADCmux = Line_IN1 */ | 306 | /* ADCmux = Line_IN1 or Line_IN2 */ |
296 | as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_LINE_IN1, | 307 | as3514_write_masked(AS3514_ADC_R, |
308 | (LINE_INPUT == 1) ? ADC_R_ADCMUX_LINE_IN1 : | ||
309 | ADC_R_ADCMUX_LINE_IN2, | ||
297 | ADC_R_ADCMUX); | 310 | ADC_R_ADCMUX); |
298 | 311 | ||
299 | /* MIC1_off, LIN1_on */ | 312 | /* LIN1_or LIN2 on, rest off */ |
300 | as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on, | 313 | as3514_write_masked(AS3514_AUDIOSET1, |
301 | AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); | 314 | (LINE_INPUT == 1) ? AUDIOSET1_LIN1_on : |
315 | AUDIOSET1_LIN2_on, | ||
316 | AUDIOSET1_INPUT_MASK); | ||
302 | } | 317 | } |
303 | 318 | ||
304 | /* ADC_Mute_off */ | 319 | /* ADC_Mute_off */ |
@@ -312,10 +327,8 @@ void audiohw_disable_recording(void) | |||
312 | /* ADC_Mute_on */ | 327 | /* ADC_Mute_on */ |
313 | as3514_clear(AS3514_ADC_L, ADC_L_ADC_MUTE_off); | 328 | as3514_clear(AS3514_ADC_L, ADC_L_ADC_MUTE_off); |
314 | 329 | ||
315 | /* ADC_off, LIN1_off, MIC_off */ | 330 | /* ADC_off, all input sources off */ |
316 | as3514_clear(AS3514_AUDIOSET1, | 331 | as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_ADC_on | AUDIOSET1_INPUT_MASK); |
317 | AUDIOSET1_ADC_on | AUDIOSET1_LIN1_on | | ||
318 | AUDIOSET1_MIC1_on); | ||
319 | } | 332 | } |
320 | 333 | ||
321 | /** | 334 | /** |
@@ -366,22 +379,35 @@ void audiohw_set_recvol(int left, int right, int type) | |||
366 | as3514_write_masked(AS3514_ADC_R, right, AS3514_VOL_MASK); | 379 | as3514_write_masked(AS3514_ADC_R, right, AS3514_VOL_MASK); |
367 | as3514_write_masked(AS3514_ADC_L, left, AS3514_VOL_MASK); | 380 | as3514_write_masked(AS3514_ADC_L, left, AS3514_VOL_MASK); |
368 | } | 381 | } |
382 | #endif /* HAVE_RECORDING */ | ||
369 | 383 | ||
384 | #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) | ||
370 | /** | 385 | /** |
371 | * Enable line in 1 analog monitoring | 386 | * Enable line in analog monitoring |
372 | * | 387 | * |
373 | */ | 388 | */ |
374 | void audiohw_set_monitor(bool enable) | 389 | void audiohw_set_monitor(bool enable) |
375 | { | 390 | { |
376 | if (enable) { | 391 | if (enable) { |
377 | as3514_set(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); | 392 | /* select either LIN1 or LIN2 */ |
378 | as3514_set(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); | 393 | as3514_write_masked(AS3514_AUDIOSET1, |
379 | as3514_set(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); | 394 | (LINE_INPUT == 1) ? |
395 | AUDIOSET1_LIN1_on : AUDIOSET1_LIN2_on, | ||
396 | AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); | ||
397 | as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_R : AS3514_LINE_IN2_R, | ||
398 | LINE_IN1_R_LI1R_MUTE_off); | ||
399 | as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_L : AS3514_LINE_IN2_L, | ||
400 | LINE_IN1_L_LI1L_MUTE_off); | ||
380 | } | 401 | } |
381 | else { | 402 | else { |
382 | as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); | 403 | /* turn off both LIN1 and LIN2 */ |
383 | as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); | 404 | as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); |
384 | as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); | 405 | as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); |
406 | as3514_clear(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off); | ||
407 | as3514_clear(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off); | ||
408 | as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); | ||
385 | } | 409 | } |
386 | } | 410 | } |
387 | #endif /* HAVE_RECORDING */ | 411 | #endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */ |
412 | |||
413 | |||
diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index aeabb16144..53851335c8 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h | |||
@@ -202,6 +202,8 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r); | |||
202 | #define AUDIOSET1_LIN1_on (0x1 << 2) | 202 | #define AUDIOSET1_LIN1_on (0x1 << 2) |
203 | #define AUDIOSET1_MIC2_on (0x1 << 1) | 203 | #define AUDIOSET1_MIC2_on (0x1 << 1) |
204 | #define AUDIOSET1_MIC1_on (0x1 << 0) | 204 | #define AUDIOSET1_MIC1_on (0x1 << 0) |
205 | #define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \ | ||
206 | AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on | ||
205 | 207 | ||
206 | /* AUDIOSET2 (15h) */ | 208 | /* AUDIOSET2 (15h) */ |
207 | #define AUDIOSET2_BIAS_off (0x1 << 7) | 209 | #define AUDIOSET2_BIAS_off (0x1 << 7) |
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 7dba54a8a2..b173feb77f 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h | |||
@@ -272,14 +272,17 @@ void audiohw_disable_recording(void); | |||
272 | */ | 272 | */ |
273 | void audiohw_set_recvol(int left, int right, int type); | 273 | void audiohw_set_recvol(int left, int right, int type); |
274 | 274 | ||
275 | #endif /*HAVE_RECORDING*/ | ||
276 | |||
277 | #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) | ||
278 | |||
275 | /** | 279 | /** |
276 | * Enable or disable recording monitor. | 280 | * Enable or disable recording monitor. |
277 | * @param enable ture or false. | 281 | * @param enable ture or false. |
278 | */ | 282 | */ |
279 | void audiohw_set_monitor(bool enable); | 283 | void audiohw_set_monitor(bool enable); |
280 | 284 | ||
281 | #endif /*HAVE_RECORDING*/ | 285 | #endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */ |
282 | |||
283 | 286 | ||
284 | #if CONFIG_CODEC != SWCODEC | 287 | #if CONFIG_CODEC != SWCODEC |
285 | 288 | ||
diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c index 63aaf367e8..410fdfad79 100644 --- a/firmware/target/arm/as3525/audio-as3525.c +++ b/firmware/target/arm/as3525/audio-as3525.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright © 2008 Rafaël Carré | 10 | * Copyright (C) 2009 by Bertrik Sikken |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -18,20 +18,51 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "config.h" | ||
21 | #include "system.h" | 22 | #include "system.h" |
22 | #include "cpu.h" | 23 | #include "cpu.h" |
23 | #include "audio.h" | 24 | #include "audio.h" |
25 | #include "audiohw.h" | ||
24 | #include "sound.h" | 26 | #include "sound.h" |
25 | 27 | ||
26 | /* TODO */ | 28 | int audio_channels = 2; |
29 | int audio_output_source = AUDIO_SRC_PLAYBACK; | ||
27 | 30 | ||
28 | void audio_set_output_source(int source) | 31 | void audio_set_output_source(int source) |
29 | { | 32 | { |
30 | (void)source; | 33 | if ((unsigned)source >= AUDIO_NUM_SOURCES) |
31 | } | 34 | source = AUDIO_SRC_PLAYBACK; |
35 | |||
36 | audio_output_source = source; | ||
37 | } /* audio_set_output_source */ | ||
32 | 38 | ||
33 | void audio_input_mux(int source, unsigned flags) | 39 | void audio_input_mux(int source, unsigned flags) |
34 | { | 40 | { |
35 | (void)source; | 41 | static int last_source = AUDIO_SRC_PLAYBACK; |
42 | |||
36 | (void)flags; | 43 | (void)flags; |
37 | } | 44 | |
45 | switch (source) | ||
46 | { | ||
47 | default: /* playback - no recording */ | ||
48 | source = AUDIO_SRC_PLAYBACK; | ||
49 | case AUDIO_SRC_PLAYBACK: | ||
50 | audio_channels = 2; | ||
51 | if (source != last_source) | ||
52 | { | ||
53 | audiohw_set_monitor(false); | ||
54 | } | ||
55 | break; | ||
56 | |||
57 | case AUDIO_SRC_FMRADIO: /* recording and playback */ | ||
58 | audio_channels = 2; | ||
59 | if (source == last_source) | ||
60 | break; | ||
61 | |||
62 | audiohw_set_monitor(true); | ||
63 | break; | ||
64 | } /* end switch */ | ||
65 | |||
66 | last_source = source; | ||
67 | } /* audio_input_mux */ | ||
68 | |||