diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c index 6dd90bfdb7..87b59de599 100644 --- a/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c +++ b/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c | |||
@@ -18,39 +18,55 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "wm8978.h" | 21 | #include "config.h" |
22 | #include "system.h" | ||
23 | #include "audiohw.h" | ||
22 | #include "audio.h" | 24 | #include "audio.h" |
23 | 25 | ||
26 | /* Set the audio source for IIS TX */ | ||
24 | void audio_set_output_source(int source) | 27 | void audio_set_output_source(int source) |
25 | { | 28 | { |
26 | (void)source; /* TODO */ | 29 | switch (source) |
30 | { | ||
31 | default: | ||
32 | case AUDIO_SRC_PLAYBACK: | ||
33 | /* Receive data from PORT1 (SSI1) */ | ||
34 | AUDMUX_PDCR4 = AUDMUX_PDCR_RXDSEL_PORT1; | ||
35 | /* wmc_clear(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */ | ||
36 | break; | ||
37 | |||
38 | case AUDIO_SRC_FMRADIO: | ||
39 | /* External source - receive data from self (loopback to TX) */ | ||
40 | AUDMUX_PDCR4 = AUDMUX_PDCR_RXDSEL_PORT4; | ||
41 | /* wmc_set(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */ | ||
42 | break; | ||
43 | } | ||
27 | } | 44 | } |
28 | 45 | ||
29 | void audio_input_mux(int source, unsigned int flags) | 46 | void audio_input_mux(int source, unsigned int flags) |
30 | { | 47 | { |
31 | (void)flags; | 48 | /* Prevent pops from unneeded switching */ |
49 | static int last_source = AUDIO_SRC_PLAYBACK; | ||
50 | bool recording = flags & SRCF_RECORDING; | ||
51 | static bool last_recording = false; | ||
52 | |||
32 | switch (source) | 53 | switch (source) |
33 | { | 54 | { |
34 | case AUDIO_SRC_PLAYBACK: | 55 | default: |
35 | /* deselect bypass patths and set volume to -15dB */ | 56 | source = AUDIO_SRC_PLAYBACK; |
36 | wmc_clear(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (7<<2)); | 57 | /* Fallthrough */ |
37 | wmc_clear(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (7<<2)); | 58 | case AUDIO_SRC_PLAYBACK: /* playback - no recording */ |
38 | /* disable L2/R2 inputs and boost stage */ | 59 | if (source != last_source) |
39 | wmc_clear(WMC_POWER_MANAGEMENT2, | 60 | audiohw_set_recsrc(AUDIO_SRC_PLAYBACK, false); |
40 | WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR); | ||
41 | break; | 61 | break; |
42 | 62 | ||
43 | case AUDIO_SRC_FMRADIO: | 63 | case AUDIO_SRC_FMRADIO: /* recording and playback */ |
44 | /* enable L2/R2 inputs and boost stage */ | 64 | if (source != last_source || recording != last_recording) |
45 | wmc_set(WMC_POWER_MANAGEMENT2, | 65 | audiohw_set_recsrc(AUDIO_SRC_FMRADIO, recording); |
46 | WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR); | ||
47 | /* select bypass patths and set volume to 0dB */ | ||
48 | wmc_set(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (5<<2)); | ||
49 | wmc_set(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (5<<2)); | ||
50 | break; | 66 | break; |
51 | |||
52 | default: | ||
53 | source = AUDIO_SRC_PLAYBACK; | ||
54 | } | 67 | } |
68 | |||
69 | last_source = source; | ||
70 | last_recording = recording; | ||
55 | } | 71 | } |
56 | 72 | ||