summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-07-12 22:25:38 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-07-13 02:42:17 +0200
commita22855ce61b03c71695137d4ffa428e2e43a3544 (patch)
treebda2ecc7d71335521562e978476ca32d87ccc9a4 /firmware
parent93de093690c660fd4a8b0c5b9d0da2a8d903f301 (diff)
downloadrockbox-a22855ce61b03c71695137d4ffa428e2e43a3544.tar.gz
rockbox-a22855ce61b03c71695137d4ffa428e2e43a3544.tar.bz2
rockbox-a22855ce61b03c71695137d4ffa428e2e43a3544.zip
imx233: add audioout debug info
Change-Id: Iac092de861847e31aba48d2fdc51ae72cd9bd202
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx233/audioout-imx233.c28
-rw-r--r--firmware/target/arm/imx233/audioout-imx233.h19
2 files changed, 47 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/audioout-imx233.c b/firmware/target/arm/imx233/audioout-imx233.c
index d3f83c2fad..66664acdf7 100644
--- a/firmware/target/arm/imx233/audioout-imx233.c
+++ b/firmware/target/arm/imx233/audioout-imx233.c
@@ -22,6 +22,7 @@
#include "clkctrl-imx233.h"
#include "rtc-imx233.h"
#include "pcm_sampr.h"
+#include "string.h"
static int hp_vol_l, hp_vol_r;
static bool input_line1;
@@ -241,4 +242,31 @@ void imx233_audioout_set_3d_effect(int val)
/* others: off */
default: BF_WR(AUDIOOUT_CTRL, SS3D_EFFECT, 0); break;
}
+}
+
+struct imx233_audioout_info_t imx233_audioout_get_info(void)
+{
+ struct imx233_audioout_info_t info;
+ memset(&info, 0, sizeof(info));
+ /* 6*10^6*basemult/(src_frac*8*(src_hold+1)) in Hz */
+ info.freq = 60000000 * BF_RD(AUDIOOUT_DACSRR, BASEMULT) / 8 /
+ BF_RD(AUDIOOUT_DACSRR, SRC_FRAC) / (1 + BF_RD(AUDIOOUT_DACSRR, SRC_HOLD));
+ info.hp_line1 = BF_RD(AUDIOOUT_HPVOL, SELECT);
+ /* convert half-dB to tenth-dB */
+ info.dacvol[0] = MAX((int)BF_RD(AUDIOOUT_DACVOLUME, VOLUME_LEFT) - 0xff, -100) * 5;
+ info.dacvol[1] = MAX((int)BF_RD(AUDIOOUT_DACVOLUME, VOLUME_RIGHT) - 0xff, -100) * 5;
+ info.dacmute[0] = BF_RD(AUDIOOUT_DACVOLUME, MUTE_LEFT);
+ info.dacmute[1] = BF_RD(AUDIOOUT_DACVOLUME, MUTE_RIGHT);
+ info.hpvol[0] = (info.hp_line1 ? 120 : 60) - 5 * BF_RD(AUDIOOUT_HPVOL, VOL_LEFT);
+ info.hpvol[1] = (info.hp_line1 ? 120 : 60) - 5 * BF_RD(AUDIOOUT_HPVOL, VOL_RIGHT);
+ info.hpmute[0] = info.hpmute[1] = BF_RD(AUDIOOUT_HPVOL, MUTE);
+ info.spkrvol[0] = info.spkrvol[1] = 155;
+ info.spkrmute[0] = info.spkrmute[1] = BF_RD(AUDIOOUT_SPEAKERCTRL, MUTE);
+ info.ss3d = BF_RD(AUDIOOUT_CTRL, SS3D_EFFECT);
+ info.ss3d = info.ss3d == 0 ? 0 : 15 * (1 + info.ss3d);
+ info.hp = !BF_RD(AUDIOOUT_PWRDN, HEADPHONE);
+ info.dac = !BF_RD(AUDIOOUT_PWRDN, DAC);
+ info.capless = BF_RD(AUDIOOUT_PWRDN, CAPLESS);
+ info.spkr = !BF_RD(AUDIOOUT_PWRDN, SPEAKER);
+ return info;
} \ No newline at end of file
diff --git a/firmware/target/arm/imx233/audioout-imx233.h b/firmware/target/arm/imx233/audioout-imx233.h
index fba737c72a..c7fcf647a4 100644
--- a/firmware/target/arm/imx233/audioout-imx233.h
+++ b/firmware/target/arm/imx233/audioout-imx233.h
@@ -27,6 +27,23 @@
#include "regs/regs-audioout.h"
+struct imx233_audioout_info_t
+{
+ int freq; // in mHz
+ bool hp_line1;
+ bool dac;
+ int dacvol[2]; // in tenth-dB, l/r
+ bool dacmute[2]; // l/r
+ bool hp;
+ int hpvol[2]; // in tenth-db, l/r
+ bool hpmute[2]; // l/r
+ bool spkr;
+ int spkrvol[2]; // in tenth-db, l/r
+ int spkrmute[2]; // l/r
+ int ss3d; // in tenth-db
+ bool capless;
+};
+
void imx233_audioout_preinit(void);
void imx233_audioout_postinit(void);
void imx233_audioout_close(void);
@@ -39,4 +56,6 @@ void imx233_audioout_select_hp_input(bool line1);
/* value in 1.5dB steps, from 0dB to 6dB */
void imx233_audioout_set_3d_effect(int val);
+struct imx233_audioout_info_t imx233_audioout_get_info(void);
+
#endif /* __audioout_imx233__ */