summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-07-13 02:41:17 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-07-13 02:42:17 +0200
commit8c91d05543aebb8de874270f0b770ef3e56b00bb (patch)
treeb1349dfa6f9da9d3614565fbb5c5f318ffbe4408 /firmware
parent15c8ec8987faa16741b6016deaa8a2ed671c41de (diff)
downloadrockbox-8c91d05543aebb8de874270f0b770ef3e56b00bb.tar.gz
rockbox-8c91d05543aebb8de874270f0b770ef3e56b00bb.tar.bz2
rockbox-8c91d05543aebb8de874270f0b770ef3e56b00bb.zip
imx233: add audioin debug info
Change-Id: Iba6e2b720489c1d2178a44a0a4fe5df2a7540579
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx233/audioin-imx233.c28
-rw-r--r--firmware/target/arm/imx233/audioin-imx233.h18
2 files changed, 45 insertions, 1 deletions
diff --git a/firmware/target/arm/imx233/audioin-imx233.c b/firmware/target/arm/imx233/audioin-imx233.c
index 6c2a212c4d..859e65f813 100644
--- a/firmware/target/arm/imx233/audioin-imx233.c
+++ b/firmware/target/arm/imx233/audioin-imx233.c
@@ -20,6 +20,7 @@
****************************************************************************/
#include "audioin-imx233.h"
#include "pcm_sampr.h"
+#include "string.h"
/* values in half-dB, one for each setting */
static int audioin_vol[2][4]; /* 0=left, 1=right */
@@ -79,7 +80,7 @@ static void apply_config(void)
* - microphone: -100dB -> 62dB in 0.5dB steps
*/
- /* First apply mic gain of possible and necessary
+ /* First apply mic gain if possible and necessary
* Only left volume is relevant with microphone
* If gain is > 22dB, use mic gain */
if(select_l == AUDIOIN_SELECT_MICROPHONE && vol_l > 22 * 2)
@@ -188,3 +189,28 @@ void imx233_audioin_set_freq(int fsel)
SRC_FRAC(dacssr[fsel].src_frac), SRC_INT(dacssr[fsel].src_int),
SRC_HOLD(dacssr[fsel].src_hold), BASEMULT(dacssr[fsel].base_mult));
}
+
+struct imx233_audioin_info_t imx233_audioin_get_info(void)
+{
+ struct imx233_audioin_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(AUDIOIN_ADCSRR, BASEMULT) / 8 /
+ BF_RD(AUDIOIN_ADCSRR, SRC_FRAC) / (1 + BF_RD(AUDIOIN_ADCSRR, SRC_HOLD));
+ info.muxselect[0] = BF_RD(AUDIOIN_ADCVOL, SELECT_LEFT);
+ info.muxselect[1] = BF_RD(AUDIOIN_ADCVOL, SELECT_RIGHT);
+ /* convert half-dB to tenth-dB */
+ info.muxvol[0] = BF_RD(AUDIOIN_ADCVOL, GAIN_LEFT) * 15;
+ info.muxvol[1] = BF_RD(AUDIOIN_ADCVOL, GAIN_RIGHT) * 15;
+ info.muxmute[0] = info.adcmute[1] = BF_RD(AUDIOIN_ADCVOL, MUTE);
+ info.adcvol[0] = MAX((int)BF_RD(AUDIOIN_ADCVOLUME, VOLUME_LEFT) - 0xff, -100) * 5;
+ info.adcvol[1] = MAX((int)BF_RD(AUDIOIN_ADCVOLUME, VOLUME_RIGHT) - 0xff, -100) * 5;
+ info.adcmute[0] = info.adcmute[1] = false;
+ info.micvol[0] = BF_RD(AUDIOIN_MICLINE, MIC_GAIN);
+ if(info.micvol[0] != 0)
+ info.micvol[0] = info.micvol[1] = info.micvol[0] * 100 + 100;
+ info.micmute[0] = info.micmute[1] = false;
+ info.adc = !BF_RD(AUDIOOUT_PWRDN, ADC);
+ info.mic = info.mux = true;
+ return info;
+}
diff --git a/firmware/target/arm/imx233/audioin-imx233.h b/firmware/target/arm/imx233/audioin-imx233.h
index a36cbf6e1a..12c7b1dad5 100644
--- a/firmware/target/arm/imx233/audioin-imx233.h
+++ b/firmware/target/arm/imx233/audioin-imx233.h
@@ -34,6 +34,22 @@
#define AUDIOIN_SELECT_HEADPHONE 2
#define AUDIOIN_SELECT_LINE2 3
+struct imx233_audioin_info_t
+{
+ // NOTE there is a convention here: adc -> adcvol -> adcmute
+ int freq; // in mHz
+ int muxselect[2];
+ bool adc;
+ int adcvol[2]; // in tenth-dB, l/r
+ bool adcmute[2]; // l/r
+ bool mux;
+ int muxvol[2]; // in tenth-db, l/r
+ bool muxmute[2]; // l/r
+ bool mic;
+ int micvol[2]; // in tenth-db, l/r
+ int micmute[2]; // l/r
+};
+
void imx233_audioin_preinit(void);
void imx233_audioin_postinit(void);
void imx233_audioin_open(void);
@@ -47,4 +63,6 @@ void imx233_audioin_set_freq(int fsel);
/* enable microphone */
void imx233_audioin_enable_mic(bool enable);
+struct imx233_audioin_info_t imx233_audioin_get_info(void);
+
#endif /* __audioin_imx233__ */