summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/audioout-imx233.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/audioout-imx233.c')
-rw-r--r--firmware/target/arm/imx233/audioout-imx233.c28
1 files changed, 28 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