diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-02-03 19:58:25 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-02-03 20:04:39 +0100 |
commit | 1a083cdaccb3598de834c3643c5bc02716af804d (patch) | |
tree | 05536822b84d48e1d5d71954646b7ae52e03f04a /firmware | |
parent | 7d54ff069ba36702b58d1dd6bb8a8ab03297f9e2 (diff) | |
download | rockbox-1a083cdaccb3598de834c3643c5bc02716af804d.tar.gz rockbox-1a083cdaccb3598de834c3643c5bc02716af804d.zip |
imx233/fuze+: fix a typo, handle volume differently because of the line1/dac mode difference.
The headphone volume register value reads differently in Line1 and DAC mode.
Since the volume is not set again when switching between playback and radio,
we need to remember the hp volume and reapply setting when changing the mode.
Change-Id: I8fbd344f78653c19d81a39dd3f680ec6885cb1ec
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/imx233-codec.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/imx233/audioout-imx233.c | 42 | ||||
-rw-r--r-- | firmware/target/arm/imx233/audioout-imx233.h | 3 | ||||
-rw-r--r-- | firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c | 4 |
4 files changed, 41 insertions, 12 deletions
diff --git a/firmware/drivers/audio/imx233-codec.c b/firmware/drivers/audio/imx233-codec.c index d99a4d0ca9..20edf005e8 100644 --- a/firmware/drivers/audio/imx233-codec.c +++ b/firmware/drivers/audio/imx233-codec.c | |||
@@ -69,9 +69,7 @@ void audiohw_close(void) | |||
69 | 69 | ||
70 | void audiohw_set_headphone_vol(int vol_l, int vol_r) | 70 | void audiohw_set_headphone_vol(int vol_l, int vol_r) |
71 | { | 71 | { |
72 | /* Use playback volume if <0 and headphone volume if >0 */ | 72 | imx233_audioout_set_hp_vol(vol_l, vol_r); |
73 | imx233_audioout_set_dac_vol(MIN(0, vol_l), MIN(0, vol_r)); | ||
74 | imx233_audioout_set_hp_vol(MAX(0, vol_l), MAX(0, vol_r)); | ||
75 | } | 73 | } |
76 | 74 | ||
77 | void audiohw_set_frequency(int fsel) | 75 | void audiohw_set_frequency(int fsel) |
diff --git a/firmware/target/arm/imx233/audioout-imx233.c b/firmware/target/arm/imx233/audioout-imx233.c index 0a48a909e8..e03de5c861 100644 --- a/firmware/target/arm/imx233/audioout-imx233.c +++ b/firmware/target/arm/imx233/audioout-imx233.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include "rtc-imx233.h" | 23 | #include "rtc-imx233.h" |
24 | #include "pcm_sampr.h" | 24 | #include "pcm_sampr.h" |
25 | 25 | ||
26 | static int hp_vol_l, hp_vol_r; | ||
27 | |||
26 | void imx233_audioout_preinit(void) | 28 | void imx233_audioout_preinit(void) |
27 | { | 29 | { |
28 | /* Enable AUDIOOUT block */ | 30 | /* Enable AUDIOOUT block */ |
@@ -78,8 +80,10 @@ void imx233_audioout_close(void) | |||
78 | /* will also gate off the module */ | 80 | /* will also gate off the module */ |
79 | __REG_CLR(HW_AUDIOOUT_CTRL) = HW_AUDIOOUT_CTRL__RUN; | 81 | __REG_CLR(HW_AUDIOOUT_CTRL) = HW_AUDIOOUT_CTRL__RUN; |
80 | } | 82 | } |
81 | /* volume in half dB */ | 83 | |
82 | void imx233_audioout_set_dac_vol(int vol_l, int vol_r) | 84 | /* volume in half dB |
85 | * don't check input values */ | ||
86 | static void set_dac_vol(int vol_l, int vol_r) | ||
83 | { | 87 | { |
84 | /* minimum is -100dB and max is 0dB */ | 88 | /* minimum is -100dB and max is 0dB */ |
85 | vol_l = MAX(-200, MIN(vol_l, 0)); | 89 | vol_l = MAX(-200, MIN(vol_l, 0)); |
@@ -92,14 +96,16 @@ void imx233_audioout_set_dac_vol(int vol_l, int vol_r) | |||
92 | HW_AUDIOOUT_DACVOLUME__EN_ZCD; | 96 | HW_AUDIOOUT_DACVOLUME__EN_ZCD; |
93 | } | 97 | } |
94 | 98 | ||
95 | void imx233_audioout_set_hp_vol(int vol_l, int vol_r) | 99 | /* volume in half dB |
100 | * don't check input values */ | ||
101 | static void set_hp_vol(int vol_l, int vol_r) | ||
96 | { | 102 | { |
97 | uint32_t select = (HW_AUDIOOUT_HPVOL & HW_AUDIOOUT_HPVOL__SELECT); | 103 | uint32_t select = (HW_AUDIOOUT_HPVOL & HW_AUDIOOUT_HPVOL__SELECT); |
98 | /* minimum is -57.5dB and max is 6dB in DAC mode | 104 | /* minimum is -57.5dB and max is 6dB in DAC mode |
99 | * and -51.5dB / 12dB in Line1 mode */ | 105 | * and -51.5dB / 12dB in Line1 mode */ |
100 | int min = select ? -103 : -115; | 106 | int min = select ? -103 : -115; |
101 | int max = select ? 24 : 12; | 107 | int max = select ? 24 : 12; |
102 | 108 | ||
103 | vol_l = MAX(min, MIN(vol_l, max)); | 109 | vol_l = MAX(min, MIN(vol_l, max)); |
104 | vol_r = MAX(min, MIN(vol_r, max)); | 110 | vol_r = MAX(min, MIN(vol_r, max)); |
105 | /* unmute, enable zero cross and set volume. Keep select value. */ | 111 | /* unmute, enable zero cross and set volume. Keep select value. */ |
@@ -110,6 +116,30 @@ void imx233_audioout_set_hp_vol(int vol_l, int vol_r) | |||
110 | HW_AUDIOOUT_HPVOL__EN_MSTR_ZCD; | 116 | HW_AUDIOOUT_HPVOL__EN_MSTR_ZCD; |
111 | } | 117 | } |
112 | 118 | ||
119 | static void apply_volume(void) | ||
120 | { | ||
121 | /* Two cases: line1 and dac */ | ||
122 | if(HW_AUDIOOUT_HPVOL & HW_AUDIOOUT_HPVOL__SELECT) | ||
123 | { | ||
124 | /* In line1 mode, the HP is the only way to adjust the volume */ | ||
125 | set_hp_vol(hp_vol_l, hp_vol_r); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | /* In DAC mode we can use both the HP and the DAC volume. | ||
130 | * Use the DAC for volume <0 and HP for volume >0 */ | ||
131 | set_dac_vol(MIN(0, hp_vol_l), MIN(0, hp_vol_r)); | ||
132 | set_hp_vol(MAX(0, hp_vol_l), MAX(0, hp_vol_r)); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | void imx233_audioout_set_hp_vol(int vol_l, int vol_r) | ||
137 | { | ||
138 | hp_vol_l = vol_l; | ||
139 | hp_vol_r = vol_r; | ||
140 | apply_volume(); | ||
141 | } | ||
142 | |||
113 | void imx233_audioout_set_freq(int fsel) | 143 | void imx233_audioout_set_freq(int fsel) |
114 | { | 144 | { |
115 | static struct | 145 | static struct |
@@ -170,10 +200,12 @@ void imx233_audioout_set_freq(int fsel) | |||
170 | } | 200 | } |
171 | 201 | ||
172 | /* select between DAC and Line1 */ | 202 | /* select between DAC and Line1 */ |
173 | void imx233_audiout_select_hp_input(bool line1) | 203 | void imx233_audioout_select_hp_input(bool line1) |
174 | { | 204 | { |
175 | if(line1) | 205 | if(line1) |
176 | __REG_SET(HW_AUDIOOUT_HPVOL) = HW_AUDIOOUT_HPVOL__SELECT; | 206 | __REG_SET(HW_AUDIOOUT_HPVOL) = HW_AUDIOOUT_HPVOL__SELECT; |
177 | else | 207 | else |
178 | __REG_CLR(HW_AUDIOOUT_HPVOL) = HW_AUDIOOUT_HPVOL__SELECT; | 208 | __REG_CLR(HW_AUDIOOUT_HPVOL) = HW_AUDIOOUT_HPVOL__SELECT; |
209 | /* reapply volume setting */ | ||
210 | apply_volume(); | ||
179 | } | 211 | } |
diff --git a/firmware/target/arm/imx233/audioout-imx233.h b/firmware/target/arm/imx233/audioout-imx233.h index cd997e7d31..acfb56138f 100644 --- a/firmware/target/arm/imx233/audioout-imx233.h +++ b/firmware/target/arm/imx233/audioout-imx233.h | |||
@@ -112,11 +112,10 @@ void imx233_audioout_preinit(void); | |||
112 | void imx233_audioout_postinit(void); | 112 | void imx233_audioout_postinit(void); |
113 | void imx233_audioout_close(void); | 113 | void imx233_audioout_close(void); |
114 | /* volume in half dB */ | 114 | /* volume in half dB */ |
115 | void imx233_audioout_set_dac_vol(int vol_l, int vol_r); | ||
116 | void imx233_audioout_set_hp_vol(int vol_l, int vol_r); | 115 | void imx233_audioout_set_hp_vol(int vol_l, int vol_r); |
117 | /* frequency index, NOT the frequency itself */ | 116 | /* frequency index, NOT the frequency itself */ |
118 | void imx233_audioout_set_freq(int fsel); | 117 | void imx233_audioout_set_freq(int fsel); |
119 | /* select between DAC and Line1 */ | 118 | /* select between DAC and Line1 */ |
120 | void imx233_audiout_select_hp_input(bool line1); | 119 | void imx233_audioout_select_hp_input(bool line1); |
121 | 120 | ||
122 | #endif /* __audioout_imx233__ */ | 121 | #endif /* __audioout_imx233__ */ |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c index abdcda90cb..57a3efd642 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c | |||
@@ -32,9 +32,9 @@ static int output_source = AUDIO_SRC_PLAYBACK; | |||
32 | static void select_audio_path(void) | 32 | static void select_audio_path(void) |
33 | { | 33 | { |
34 | if(input_source == AUDIO_SRC_PLAYBACK) | 34 | if(input_source == AUDIO_SRC_PLAYBACK) |
35 | imx233_audiout_select_hp_input(false); | 35 | imx233_audioout_select_hp_input(false); |
36 | else | 36 | else |
37 | imx233_audiout_select_hp_input(true); | 37 | imx233_audioout_select_hp_input(true); |
38 | } | 38 | } |
39 | 39 | ||
40 | void audio_input_mux(int source, unsigned flags) | 40 | void audio_input_mux(int source, unsigned flags) |