diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-05-14 23:34:24 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-05-14 23:34:24 +0000 |
commit | a238ab9df8f19ecd7abc44b6707a5622fcd770fe (patch) | |
tree | d6f786b92d649166545d235b2a4dfb72fe54ba7f /firmware/drivers/uda1380.c | |
parent | c9a1b4e9aaba244d27a1e770052697bab8a6ae3e (diff) | |
download | rockbox-a238ab9df8f19ecd7abc44b6707a5622fcd770fe.tar.gz rockbox-a238ab9df8f19ecd7abc44b6707a5622fcd770fe.zip |
Iriver: Moved the handling of the UDA1380 split gain (analog preamp + decimator gain) into the UDA driver. * All: Settings structure sorted & cleaned up.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9927 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/uda1380.c')
-rw-r--r-- | firmware/drivers/uda1380.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c index e787c1c253..5a0ecf08ca 100644 --- a/firmware/drivers/uda1380.c +++ b/firmware/drivers/uda1380.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "file.h" | 29 | #include "file.h" |
30 | #include "buffer.h" | 30 | #include "buffer.h" |
31 | #include "audio.h" | 31 | #include "audio.h" |
32 | #include "logf.h" | ||
32 | 33 | ||
33 | #include "i2c-coldfire.h" | 34 | #include "i2c-coldfire.h" |
34 | #include "uda1380.h" | 35 | #include "uda1380.h" |
@@ -255,27 +256,37 @@ void uda1380_disable_recording(void) | |||
255 | /** | 256 | /** |
256 | * Set recording gain and volume | 257 | * Set recording gain and volume |
257 | * | 258 | * |
258 | * type: params: ranges: | 259 | * type: params: ranges: |
259 | * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain | 260 | * AUDIO_GAIN_MIC: left -128 .. 108 -> -64 .. 54 dB gain |
260 | * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain | 261 | * AUDIO_GAIN_LINEIN left & right -128 .. 96 -> -64 .. 48 dB gain |
261 | * AUDIO_GAIN_DECIMATOR left & right -128 .. 48 -> -64 .. 24 dB gain | ||
262 | * | 262 | * |
263 | * Note: For all types the value 0 gives 0 dB gain. | 263 | * Note: For all types the value 0 gives 0 dB gain. |
264 | */ | 264 | */ |
265 | void uda1380_set_recvol(int left, int right, int type) | 265 | void uda1380_set_recvol(int left, int right, int type) |
266 | { | 266 | { |
267 | int left_ag, right_ag; | ||
268 | |||
267 | switch (type) | 269 | switch (type) |
268 | { | 270 | { |
269 | case AUDIO_GAIN_MIC: | 271 | case AUDIO_GAIN_MIC: |
270 | uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK) | VGA_GAIN(left)); | 272 | left_ag = MIN(MAX(0, left / 4), 15); |
273 | left -= left_ag * 4; | ||
274 | uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK) | ||
275 | | VGA_GAIN(left_ag)); | ||
276 | uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(left)); | ||
277 | logf("Mic: %dA/%dD", left_ag, left); | ||
271 | break; | 278 | break; |
272 | 279 | ||
273 | case AUDIO_GAIN_LINEIN: | 280 | case AUDIO_GAIN_LINEIN: |
274 | uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right)); | 281 | left_ag = MIN(MAX(0, left / 6), 8); |
275 | break; | 282 | left -= left_ag * 6; |
276 | 283 | right_ag = MIN(MAX(0, right / 6), 8); | |
277 | case AUDIO_GAIN_DECIMATOR: | 284 | right -= right_ag * 6; |
285 | uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | ||
286 | | PGA_GAINL(left_ag) | PGA_GAINR(right_ag)); | ||
278 | uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right)); | 287 | uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right)); |
288 | logf("Line L: %dA/%dD", left_ag, left); | ||
289 | logf("Line R: %dA/%dD", right_ag, right); | ||
279 | break; | 290 | break; |
280 | } | 291 | } |
281 | } | 292 | } |