summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233')
-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 @@
22#include "clkctrl-imx233.h" 22#include "clkctrl-imx233.h"
23#include "rtc-imx233.h" 23#include "rtc-imx233.h"
24#include "pcm_sampr.h" 24#include "pcm_sampr.h"
25#include "string.h"
25 26
26static int hp_vol_l, hp_vol_r; 27static int hp_vol_l, hp_vol_r;
27static bool input_line1; 28static bool input_line1;
@@ -241,4 +242,31 @@ void imx233_audioout_set_3d_effect(int val)
241 /* others: off */ 242 /* others: off */
242 default: BF_WR(AUDIOOUT_CTRL, SS3D_EFFECT, 0); break; 243 default: BF_WR(AUDIOOUT_CTRL, SS3D_EFFECT, 0); break;
243 } 244 }
245}
246
247struct imx233_audioout_info_t imx233_audioout_get_info(void)
248{
249 struct imx233_audioout_info_t info;
250 memset(&info, 0, sizeof(info));
251 /* 6*10^6*basemult/(src_frac*8*(src_hold+1)) in Hz */
252 info.freq = 60000000 * BF_RD(AUDIOOUT_DACSRR, BASEMULT) / 8 /
253 BF_RD(AUDIOOUT_DACSRR, SRC_FRAC) / (1 + BF_RD(AUDIOOUT_DACSRR, SRC_HOLD));
254 info.hp_line1 = BF_RD(AUDIOOUT_HPVOL, SELECT);
255 /* convert half-dB to tenth-dB */
256 info.dacvol[0] = MAX((int)BF_RD(AUDIOOUT_DACVOLUME, VOLUME_LEFT) - 0xff, -100) * 5;
257 info.dacvol[1] = MAX((int)BF_RD(AUDIOOUT_DACVOLUME, VOLUME_RIGHT) - 0xff, -100) * 5;
258 info.dacmute[0] = BF_RD(AUDIOOUT_DACVOLUME, MUTE_LEFT);
259 info.dacmute[1] = BF_RD(AUDIOOUT_DACVOLUME, MUTE_RIGHT);
260 info.hpvol[0] = (info.hp_line1 ? 120 : 60) - 5 * BF_RD(AUDIOOUT_HPVOL, VOL_LEFT);
261 info.hpvol[1] = (info.hp_line1 ? 120 : 60) - 5 * BF_RD(AUDIOOUT_HPVOL, VOL_RIGHT);
262 info.hpmute[0] = info.hpmute[1] = BF_RD(AUDIOOUT_HPVOL, MUTE);
263 info.spkrvol[0] = info.spkrvol[1] = 155;
264 info.spkrmute[0] = info.spkrmute[1] = BF_RD(AUDIOOUT_SPEAKERCTRL, MUTE);
265 info.ss3d = BF_RD(AUDIOOUT_CTRL, SS3D_EFFECT);
266 info.ss3d = info.ss3d == 0 ? 0 : 15 * (1 + info.ss3d);
267 info.hp = !BF_RD(AUDIOOUT_PWRDN, HEADPHONE);
268 info.dac = !BF_RD(AUDIOOUT_PWRDN, DAC);
269 info.capless = BF_RD(AUDIOOUT_PWRDN, CAPLESS);
270 info.spkr = !BF_RD(AUDIOOUT_PWRDN, SPEAKER);
271 return info;
244} \ No newline at end of file 272} \ 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 @@
27 27
28#include "regs/regs-audioout.h" 28#include "regs/regs-audioout.h"
29 29
30struct imx233_audioout_info_t
31{
32 int freq; // in mHz
33 bool hp_line1;
34 bool dac;
35 int dacvol[2]; // in tenth-dB, l/r
36 bool dacmute[2]; // l/r
37 bool hp;
38 int hpvol[2]; // in tenth-db, l/r
39 bool hpmute[2]; // l/r
40 bool spkr;
41 int spkrvol[2]; // in tenth-db, l/r
42 int spkrmute[2]; // l/r
43 int ss3d; // in tenth-db
44 bool capless;
45};
46
30void imx233_audioout_preinit(void); 47void imx233_audioout_preinit(void);
31void imx233_audioout_postinit(void); 48void imx233_audioout_postinit(void);
32void imx233_audioout_close(void); 49void imx233_audioout_close(void);
@@ -39,4 +56,6 @@ void imx233_audioout_select_hp_input(bool line1);
39/* value in 1.5dB steps, from 0dB to 6dB */ 56/* value in 1.5dB steps, from 0dB to 6dB */
40void imx233_audioout_set_3d_effect(int val); 57void imx233_audioout_set_3d_effect(int val);
41 58
59struct imx233_audioout_info_t imx233_audioout_get_info(void);
60
42#endif /* __audioout_imx233__ */ 61#endif /* __audioout_imx233__ */