diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/uda1380.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c index e89f9bb684..6a5bd078c0 100644 --- a/firmware/drivers/uda1380.c +++ b/firmware/drivers/uda1380.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "string.h" | 28 | #include "string.h" |
29 | #include "file.h" | 29 | #include "file.h" |
30 | #include "buffer.h" | 30 | #include "buffer.h" |
31 | #include "audio.h" | ||
31 | 32 | ||
32 | #include "i2c-coldfire.h" | 33 | #include "i2c-coldfire.h" |
33 | #include "uda1380.h" | 34 | #include "uda1380.h" |
@@ -204,7 +205,7 @@ void uda1380_close(void) | |||
204 | * sound samples over the I2S bus, which is connected | 205 | * sound samples over the I2S bus, which is connected |
205 | * to the processor's IIS1 interface. | 206 | * to the processor's IIS1 interface. |
206 | * | 207 | * |
207 | * source_mic: true=record from microphone, false=record from line-in | 208 | * source_mic: true=record from microphone, false=record from line-in (or radio) |
208 | */ | 209 | */ |
209 | void uda1380_enable_recording(bool source_mic) | 210 | void uda1380_enable_recording(bool source_mic) |
210 | { | 211 | { |
@@ -246,17 +247,29 @@ void uda1380_disable_recording(void) | |||
246 | /** | 247 | /** |
247 | * Set recording gain and volume | 248 | * Set recording gain and volume |
248 | * | 249 | * |
249 | * mic_gain : range 0 .. 15 -> 0 .. 30 dB gain | 250 | * type: params: ranges: |
250 | * linein_gain : range 0 .. 15 -> 0 .. 24 dB gain | 251 | * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain |
251 | * | 252 | * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain |
252 | * adc_volume : range -127 .. 48 -> -63 .. 24 dB gain | 253 | * AUDIO_GAIN_ADC left & right -128 .. 48 -> -64 .. 24 dB gain |
253 | * note that 0 -> 0 dB gain.. | 254 | * |
255 | * Note: For all types the value 0 gives 0 dB gain. | ||
254 | */ | 256 | */ |
255 | void uda1380_set_recvol(int mic_gain, int linein_gain, int adc_volume) | 257 | void uda1380_set_recvol(int left, int right, int type) |
256 | { | 258 | { |
257 | uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(adc_volume) | DEC_VOLR(adc_volume)); | 259 | switch (type) |
258 | uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(linein_gain) | PGA_GAINR(linein_gain)); | 260 | { |
259 | uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK) | VGA_GAIN(mic_gain)); | 261 | case AUDIO_GAIN_MIC: |
262 | uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK) | VGA_GAIN(left)); | ||
263 | break; | ||
264 | |||
265 | case AUDIO_GAIN_LINEIN: | ||
266 | uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right)); | ||
267 | break; | ||
268 | |||
269 | case AUDIO_GAIN_ADC: | ||
270 | uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right)); | ||
271 | break; | ||
272 | } | ||
260 | } | 273 | } |
261 | 274 | ||
262 | 275 | ||