diff --git a/apps/keymaps/keymap-clip.c b/apps/keymaps/keymap-clip.c index 2dcc7e3..75bda4e 100644 --- a/apps/keymaps/keymap-clip.c +++ b/apps/keymaps/keymap-clip.c @@ -212,12 +212,19 @@ static const struct button_mapping button_context_recscreen[] = { /** FM Radio Screen **/ static const struct button_mapping button_context_radio[] = { - { ACTION_FM_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_FM_PRESET, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, - { ACTION_FM_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_NONE }, - { ACTION_FM_MODE, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, - { ACTION_FM_EXIT, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, - { ACTION_FM_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + /* Copied from keymap-c200.c 20081207. Feel free to suggest a better one.*/ + { ACTION_NONE, BUTTON_UP, BUTTON_NONE }, + { ACTION_FM_MENU, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_FM_PRESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_FM_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_FM_MODE, BUTTON_HOME, BUTTON_NONE }, + { ACTION_FM_EXIT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_FM_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) }; /* button_context_radio */ diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 23d1c52..a54e913 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c @@ -31,6 +31,14 @@ #include "i2s.h" #include "ascodec.h" +/* AMS Sansas based on the AS3525 use the LINE2 input for the analog radio + signal instead of LINE1 */ +#if CONFIG_CPU == AS3525 +#define LINE_INPUT 2 +#else +#define LINE_INPUT 1 +#endif + const struct sound_settings_info audiohw_settings[] = { [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, /* HAVE_SW_TONE_CONTROLS */ @@ -228,8 +236,10 @@ void audiohw_set_master_vol(int vol_l, int vol_r) as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); #ifdef HAVE_RECORDING - as3514_write_masked(AS3514_LINE_IN1_R, mix_r, AS3514_VOL_MASK); - as3514_write_masked(AS3514_LINE_IN1_L, mix_l, AS3514_VOL_MASK); + as3514_write_masked(LINE_INPUT == 1 ? AS3514_LINE_IN1_R : AS3514_LINE_IN2_R, + mix_r, AS3514_VOL_MASK); + as3514_write_masked(LINE_INPUT == 1 ? AS3514_LINE_IN1_L : AS3514_LINE_IN2_L, + mix_l, AS3514_VOL_MASK); #endif as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK); as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK); @@ -237,10 +247,8 @@ void audiohw_set_master_vol(int vol_l, int vol_r) void audiohw_set_lineout_vol(int vol_l, int vol_r) { - as3514_write_masked(AS3514_LINE_OUT_R, vol_r, - AS3514_VOL_MASK); - as3514_write_masked(AS3514_LINE_OUT_L, vol_l, - AS3514_VOL_MASK); + as3514_write_masked(AS3514_LINE_OUT_R, vol_r, AS3514_VOL_MASK); + as3514_write_masked(AS3514_LINE_OUT_L, vol_l, AS3514_VOL_MASK); } void audiohw_mute(bool mute) @@ -286,19 +294,21 @@ void audiohw_enable_recording(bool source_mic) as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_ST_MIC, ADC_R_ADCMUX); - /* MIC1_on, LIN1_off */ + /* MIC1_on, others off */ as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on, - AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); + AUDIOSET1_INPUT_MASK); /* M1_AGC_off */ as3514_clear(AS3514_MIC1_R, MIC1_R_M1_AGC_off); } else { - /* ADCmux = Line_IN1 */ - as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_LINE_IN1, + /* ADCmux = Line_IN1 or Line_IN2 */ + as3514_write_masked(AS3514_ADC_R, (LINE_INPUT == 1) ? + ADC_R_ADCMUX_LINE_IN1 : ADC_R_ADCMUX_LINE_IN2, ADC_R_ADCMUX); - /* MIC1_off, LIN1_on */ - as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on, - AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); + /* LIN1_or LIN2 on, rest off */ + as3514_write_masked(AS3514_AUDIOSET1, (LINE_INPUT == 1) ? + AUDIOSET1_LIN1_on : AUDIOSET1_LIN2_on, + AUDIOSET1_INPUT_MASK); } /* ADC_Mute_off */ @@ -312,10 +322,8 @@ void audiohw_disable_recording(void) /* ADC_Mute_on */ as3514_clear(AS3514_ADC_L, ADC_L_ADC_MUTE_off); - /* ADC_off, LIN1_off, MIC_off */ - as3514_clear(AS3514_AUDIOSET1, - AUDIOSET1_ADC_on | AUDIOSET1_LIN1_on | - AUDIOSET1_MIC1_on); + /* ADC_off, all input sources off */ + as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_ADC_on | AUDIOSET1_INPUT_MASK); } /** @@ -373,15 +381,38 @@ void audiohw_set_recvol(int left, int right, int type) */ void audiohw_set_monitor(bool enable) { - if (enable) { - as3514_set(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); + audiohw_set_linein_bypass(enable ? LINE_INPUT : 0); +} +#endif /* HAVE_RECORDING */ + +/** + * Enable line-in bypass (0 = disable, 1 = linein1, 2 = linein2) + * + */ +void audiohw_set_linein_bypass(int line) +{ + switch (line) { + case 1: + as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on, + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); as3514_set(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); as3514_set(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); - } - else { - as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); + break; + + case 2: + as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN2_on, + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); + as3514_set(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off); + as3514_set(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off); + break; + + default: + /* turn off both LIN1 and LIN2 */ as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); - } + as3514_clear(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off); + as3514_clear(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off); + as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); + break; + } } -#endif /* HAVE_RECORDING */ diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index 07aa0eb..d93cac0 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -27,6 +27,7 @@ extern int tenthdb2master(int db); extern void audiohw_set_master_vol(int vol_l, int vol_r); extern void audiohw_set_lineout_vol(int vol_l, int vol_r); extern void audiohw_set_frequency(int fsel); +void audiohw_set_linein_bypass(int line); /* Register Descriptions */ #define AS3514_LINE_OUT_R 0x00 @@ -203,6 +204,8 @@ extern void audiohw_set_frequency(int fsel); #define AUDIOSET1_LIN1_on (0x1 << 2) #define AUDIOSET1_MIC2_on (0x1 << 1) #define AUDIOSET1_MIC1_on (0x1 << 0) +#define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \ + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on /* AUDIOSET2 (15h) */ #define AUDIOSET2_BIAS_off (0x1 << 7) diff --git a/firmware/export/config-clip.h b/firmware/export/config-clip.h index 0a6164f..8ebe7af 100644 --- a/firmware/export/config-clip.h +++ b/firmware/export/config-clip.h @@ -20,13 +20,12 @@ #define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ #define REC_SAMPR_DEFAULT SAMPR_22 +#endif /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) -#endif - /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -103,10 +102,8 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner */ -#if 0 /* disabled since there is no driver (yet) */ #define CONFIG_TUNER SI4700 /* in fact SI4702 but let's hope it's compatible */ //#define HAVE_TUNER_PWR_CTRL -#endif /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT diff --git a/firmware/export/config-e200v2.h b/firmware/export/config-e200v2.h index 08a672b..8b07fa8 100644 --- a/firmware/export/config-e200v2.h +++ b/firmware/export/config-e200v2.h @@ -17,10 +17,10 @@ #define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ #define REC_SAMPR_DEFAULT SAMPR_22 +#endif /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) -#endif /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -99,7 +99,7 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner - suspected to be the SI4702 */ -//#define CONFIG_TUNER SI4700 +#define CONFIG_TUNER SI4700 /* #define HAVE_TUNER_PWR_CTRL */ /* Define this for LCD backlight available */ diff --git a/firmware/export/config-fuze.h b/firmware/export/config-fuze.h index 5607e4a..060124f 100644 --- a/firmware/export/config-fuze.h +++ b/firmware/export/config-fuze.h @@ -19,8 +19,8 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) #endif +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -99,7 +99,7 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner - suspected to be the SI4702 */ -//#define CONFIG_TUNER SI4700 +#define CONFIG_TUNER SI4700 /* #define HAVE_TUNER_PWR_CTRL */ /* Define this for LCD backlight available */ diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c index 63aaf36..f694306 100644 --- a/firmware/target/arm/as3525/audio-as3525.c +++ b/firmware/target/arm/as3525/audio-as3525.c @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright © 2008 Rafaël Carré + * Copyright (C) 2007 by Michael Sevakis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,20 +18,51 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "config.h" #include "system.h" #include "cpu.h" #include "audio.h" +#include "audiohw.h" #include "sound.h" -/* TODO */ +int audio_channels = 2; +int audio_output_source = AUDIO_SRC_PLAYBACK; void audio_set_output_source(int source) { - (void)source; -} + if ((unsigned)source >= AUDIO_NUM_SOURCES) + source = AUDIO_SRC_PLAYBACK; + + audio_output_source = source; +} /* audio_set_output_source */ void audio_input_mux(int source, unsigned flags) { - (void)source; + static int last_source = AUDIO_SRC_PLAYBACK; + (void)flags; -} + + switch (source) + { + default: /* playback - no recording */ + source = AUDIO_SRC_PLAYBACK; + case AUDIO_SRC_PLAYBACK: + audio_channels = 2; + if (source != last_source) + { + audiohw_set_linein_bypass(0); + } + break; + + case AUDIO_SRC_FMRADIO: /* recording and playback */ + audio_channels = 2; + if (source == last_source) + break; + + audiohw_set_linein_bypass(2); + break; + } /* end switch */ + + last_source = source; +} /* audio_input_mux */ + diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index c8366fe..17b8e35 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -26,6 +26,7 @@ #include "ascodec-target.h" #include "dma-target.h" #include "clock-target.h" +#include "fmradio_i2c.h" #define default_interrupt(name) \ extern __attribute__((weak,alias("UIRQ"))) void name (void) @@ -263,6 +264,10 @@ void system_init(void) * We don't need the power button in the bootloader. */ ascodec_init(); ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) & (1<<2)); + +#ifdef CONFIG_TUNER + fmradio_i2c_init(); +#endif #endif /* !BOOTLOADER */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ