summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-22 20:38:40 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-22 20:38:40 +0100
commit1450f2658a59006113fdfc356f4f0033c0e6f691 (patch)
treebc95eb9820dad6e7933466ff496932955787094b /firmware
parentb9db3d3743927f28f4909861e899818372645344 (diff)
downloadrockbox-1450f2658a59006113fdfc356f4f0033c0e6f691.tar.gz
rockbox-1450f2658a59006113fdfc356f4f0033c0e6f691.tar.bz2
rockbox-1450f2658a59006113fdfc356f4f0033c0e6f691.zip
stmp3700: implement speaker support by mean of lineout
Change-Id: Ic4c8b536fde7a840d3f3f295531cc1253de6320d
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx233/audioout-imx233.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/audioout-imx233.c b/firmware/target/arm/imx233/audioout-imx233.c
index c4b40340bc..887d9d77f7 100644
--- a/firmware/target/arm/imx233/audioout-imx233.c
+++ b/firmware/target/arm/imx233/audioout-imx233.c
@@ -264,6 +264,11 @@ void imx233_audioout_set_3d_effect(int val)
void imx233_audioout_enable_spkr(bool en)
{
+ /* avoid power sequence if not needed */
+ static bool spkr_en = false;
+ if(en == spkr_en)
+ return;
+ spkr_en = true;
#if IMX233_SUBTARGET >= 3780
if(en)
{
@@ -275,6 +280,38 @@ void imx233_audioout_enable_spkr(bool en)
BF_SET(AUDIOOUT_SPEAKERCTRL, MUTE);
BF_SET(AUDIOOUT_PWRDN, SPEAKER);
}
+#elif IMX233_SUBTARGET >= 3700
+ /* assume speaker is wired to lineout */
+ if(en)
+ {
+ /** 1) make sure charge capacitors are discharged */
+ BF_WR(AUDIOOUT_LINEOUTCTRL, CHARGE_CAP, 2);
+ /** 2) set min gain, nominal vag levels and zerocross desires */
+ /* volume is decreasing with the value in the register */
+ BF_SET(AUDIOOUT_LINEOUTCTRL, VOLUME_LEFT);
+ BF_SET(AUDIOOUT_LINEOUTCTRL, VOLUME_RIGHT);
+ BF_SET(AUDIOOUT_LINEOUTCTRL, EN_LINEOUT_ZCD);
+ /* vag should be set to VDDIO/2, 0 is 1.725V, 15 is 1.350V, 25mV steps */
+ int vddio;
+ imx233_power_get_regulator(REGULATOR_VDDIO, &vddio, NULL);
+ BF_WR(AUDIOOUT_LINEOUTCTRL, VAG_CTRL, 15 - (vddio / 2 - 1350) / 25);
+ /** 3) Power up lineout */
+ BF_CLR(AUDIOOUT_PWRDN, LINEOUT);
+ /** 4) Ramp the vag */
+ BF_WR(AUDIOOUT_LINEOUTCTRL, CHARGE_CAP, 1);
+ /** 5) Unmute */
+ BF_CLR(AUDIOOUT_LINEOUTCTRL, MUTE);
+ /** 6) Ramp volume */
+ BF_WR(AUDIOOUT_LINEOUTCTRL, VOLUME_LEFT, 0);
+ BF_WR(AUDIOOUT_LINEOUTCTRL, VOLUME_RIGHT, 0);
+ }
+ else
+ {
+ /** Reverse procedure */
+ BF_SET(AUDIOOUT_LINEOUTCTRL, MUTE);
+ BF_WR(AUDIOOUT_LINEOUTCTRL, CHARGE_CAP, 2);
+ BF_SET(AUDIOOUT_PWRDN, LINEOUT);
+ }
#else
(void) en;
#endif