diff options
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r-- | firmware/drivers/audio/erosqlinux_codec.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c index b1c5aa0c4f..58104a61e6 100644 --- a/firmware/drivers/audio/erosqlinux_codec.c +++ b/firmware/drivers/audio/erosqlinux_codec.c | |||
@@ -169,6 +169,10 @@ void audiohw_set_frequency(int fsel) | |||
169 | (void)fsel; | 169 | (void)fsel; |
170 | } | 170 | } |
171 | 171 | ||
172 | /* min/max for pcm volume */ | ||
173 | const int min_pcm = -430; | ||
174 | const int max_pcm = 0; | ||
175 | |||
172 | void audiohw_set_volume(int vol_l, int vol_r) | 176 | void audiohw_set_volume(int vol_l, int vol_r) |
173 | { | 177 | { |
174 | logf("hw vol %d %d", vol_l, vol_r); | 178 | logf("hw vol %d %d", vol_l, vol_r); |
@@ -179,7 +183,7 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
179 | vol_r_hw = vol_r; | 183 | vol_r_hw = vol_r; |
180 | 184 | ||
181 | if (lineout_inserted()) { | 185 | if (lineout_inserted()) { |
182 | /* On the EROS Q/K hardware, line out is _very_ hot | 186 | /* On the EROS Q/K hardware, full scale line out is _very_ hot |
183 | at ~5.8Vpp. As the hardware provides no way to reduce | 187 | at ~5.8Vpp. As the hardware provides no way to reduce |
184 | output gain, we have to back off on the PCM signal | 188 | output gain, we have to back off on the PCM signal |
185 | to avoid blowing out the signal. | 189 | to avoid blowing out the signal. |
@@ -190,10 +194,9 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
190 | r = vol_r_hw; | 194 | r = vol_r_hw; |
191 | } | 195 | } |
192 | 196 | ||
193 | /* SW volume for <= 1.0 gain, HW at unity, < -740 == MUTE */ | 197 | int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm); |
194 | int sw_volume_l = l <= -740 ? PCM_MUTE_LEVEL : MIN(l, 0); | 198 | int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm); |
195 | int sw_volume_r = r <= -740 ? PCM_MUTE_LEVEL : MIN(r, 0); | 199 | pcm_set_mixer_volume(sw_volume_l / 10, sw_volume_r / 10); |
196 | pcm_set_master_volume(sw_volume_l, sw_volume_r); | ||
197 | } | 200 | } |
198 | 201 | ||
199 | void audiohw_set_lineout_volume(int vol_l, int vol_r) | 202 | void audiohw_set_lineout_volume(int vol_l, int vol_r) |
@@ -212,7 +215,7 @@ void audiohw_set_lineout_volume(int vol_l, int vol_r) | |||
212 | r = vol_r_hw; | 215 | r = vol_r_hw; |
213 | } | 216 | } |
214 | 217 | ||
215 | int sw_volume_l = l <= -740 ? PCM_MUTE_LEVEL : MIN(l, 0); | 218 | int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm); |
216 | int sw_volume_r = r <= -740 ? PCM_MUTE_LEVEL : MIN(r, 0); | 219 | int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm); |
217 | pcm_set_master_volume(sw_volume_l, sw_volume_r); | 220 | pcm_set_mixer_volume(sw_volume_l / 10, sw_volume_r / 10); |
218 | } | 221 | } |