diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index e1c7f65..5fff134 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c @@ -63,6 +63,11 @@ #endif +#ifdef SANSA_FUZEV2 +static int as3514_vol_l; +static int as3514_vol_r; +#endif + /* Shadow registers */ static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ @@ -253,6 +258,17 @@ void audiohw_set_volume(int vol_l, int vol_r) return; } +#ifdef SANSA_FUZEV2 + as3514_vol_l = vol_l; + as3514_vol_r = vol_r; + + if (as3514_regs[AS3514_HPH_OUT_R] & HPH_OUT_R_LINEOUT) + { + /* lineout active: force to 0dB */ + vol_l = vol_r = vol_tenthdb2hw(0); + } +#endif + /* We combine the mixer/DAC channel volume range with the headphone volume range - keep first stage as loud as possible */ @@ -293,6 +309,22 @@ void audiohw_set_volume(int vol_l, int vol_r) audiohw_mute(false); } +#if defined(SANSA_FUZEV2) +void audiohw_enable_lineout(bool enable) +{ + if (enable) + { + as3514_set(AS3514_HPH_OUT_R, HPH_OUT_R_LINEOUT); + audiohw_set_volume(as3514_vol_l, as3514_vol_r); + } + else + { + as3514_clear(AS3514_HPH_OUT_R, HPH_OUT_R_LINEOUT); + audiohw_set_volume(as3514_vol_l, as3514_vol_r); + } +} +#endif + #if 0 /* unused */ void audiohw_set_lineout_volume(int vol_l, int vol_r) { diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index e9e48fa..18d3e62 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -23,6 +23,7 @@ #define _AS3514_H #include "config.h" +#include #if 0 #define AUDIOHW_CAPS (LINEOUT_CAP | LIN_GAIN_CAP | MIC_GAIN_CAP) @@ -51,6 +52,10 @@ AUDIOHW_SETTING(RIGHT_GAIN, "dB", 1, 1, 0, 31, 23, (val - 23) * 15) void audiohw_set_sampr_dividers(int fsel); +#if defined(SANSA_FUZEV2) +extern void audiohw_enable_lineout(bool enable); +#endif + /* Register Descriptions */ #ifndef HAVE_AS3543 diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h index e559647..1950fc9 100644 --- a/firmware/export/config/sansafuzev2.h +++ b/firmware/export/config/sansafuzev2.h @@ -216,5 +216,8 @@ #define INCLUDE_TIMEOUT_API +/* Define this, if you can switch on/off the lineout */ +#define HAVE_LINEOUT_POWEROFF + /* Define this if a programmable hotkey is mapped */ #define HAVE_HOTKEY diff --git a/firmware/target/arm/as3525/power-as3525.c b/firmware/target/arm/as3525/power-as3525.c index e6f1cfd..148547c 100644 --- a/firmware/target/arm/as3525/power-as3525.c +++ b/firmware/target/arm/as3525/power-as3525.c @@ -73,3 +73,11 @@ bool tuner_powered(void) return true; } #endif + +#ifdef HAVE_LINEOUT_POWEROFF +void lineout_set(bool enable) +{ + /* Call audio hardware driver implementation */ + audiohw_enable_lineout(enable); +} +#endif