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 | |
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')
-rw-r--r-- | firmware/drivers/uda1380.c | 31 | ||||
-rw-r--r-- | firmware/export/audio.h | 1 | ||||
-rw-r--r-- | firmware/export/sound.h | 4 | ||||
-rw-r--r-- | firmware/pcm_record.c | 3 | ||||
-rw-r--r-- | firmware/sound.c | 20 |
5 files changed, 27 insertions, 32 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 | } |
diff --git a/firmware/export/audio.h b/firmware/export/audio.h index b44bb91378..9e3499e81f 100644 --- a/firmware/export/audio.h +++ b/firmware/export/audio.h | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #define AUDIO_GAIN_LINEIN 0 | 36 | #define AUDIO_GAIN_LINEIN 0 |
37 | #define AUDIO_GAIN_MIC 1 | 37 | #define AUDIO_GAIN_MIC 1 |
38 | #define AUDIO_GAIN_DECIMATOR 2 /* for UDA1380 */ | ||
39 | 38 | ||
40 | 39 | ||
41 | struct audio_debug | 40 | struct audio_debug |
diff --git a/firmware/export/sound.h b/firmware/export/sound.h index dae124d8f7..a49cb99263 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h | |||
@@ -41,10 +41,6 @@ enum { | |||
41 | SOUND_RIGHT_GAIN, | 41 | SOUND_RIGHT_GAIN, |
42 | SOUND_MIC_GAIN, | 42 | SOUND_MIC_GAIN, |
43 | #endif | 43 | #endif |
44 | #if defined(HAVE_UDA1380) | ||
45 | SOUND_DECIMATOR_LEFT_GAIN, | ||
46 | SOUND_DECIMATOR_RIGHT_GAIN, | ||
47 | #endif | ||
48 | }; | 44 | }; |
49 | 45 | ||
50 | enum { | 46 | enum { |
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index 0a70494288..ea444a31e1 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c | |||
@@ -348,12 +348,11 @@ void audio_set_recording_options(int frequency, int quality, | |||
348 | * Note that microphone is mono, only left value is used | 348 | * Note that microphone is mono, only left value is used |
349 | * See uda1380_set_recvol() for exact ranges. | 349 | * See uda1380_set_recvol() for exact ranges. |
350 | * | 350 | * |
351 | * @param type 0=line-in (radio), 1=mic, 2=ADC | 351 | * @param type 0=line-in (radio), 1=mic |
352 | * | 352 | * |
353 | */ | 353 | */ |
354 | void audio_set_recording_gain(int left, int right, int type) | 354 | void audio_set_recording_gain(int left, int right, int type) |
355 | { | 355 | { |
356 | //logf("rcmrec: t=%d l=%d r=%d", type, left, right); | ||
357 | uda1380_set_recvol(left, right, type); | 356 | uda1380_set_recvol(left, right, type); |
358 | } | 357 | } |
359 | 358 | ||
diff --git a/firmware/sound.c b/firmware/sound.c index 7768afd909..057cfc0995 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -108,11 +108,9 @@ static const struct sound_settings_info sound_settings_table[] = { | |||
108 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, | 108 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, |
109 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, | 109 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, |
110 | #elif defined(HAVE_UDA1380) | 110 | #elif defined(HAVE_UDA1380) |
111 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, | 111 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, |
112 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, | 112 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, |
113 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, | 113 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, |
114 | [SOUND_DECIMATOR_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL}, | ||
115 | [SOUND_DECIMATOR_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL}, | ||
116 | #endif | 114 | #endif |
117 | }; | 115 | }; |
118 | 116 | ||
@@ -894,19 +892,11 @@ int sound_val2phys(int setting, int value) | |||
894 | { | 892 | { |
895 | case SOUND_LEFT_GAIN: | 893 | case SOUND_LEFT_GAIN: |
896 | case SOUND_RIGHT_GAIN: | 894 | case SOUND_RIGHT_GAIN: |
897 | result = value * 30; /* (24/8) *10 */ | ||
898 | break; | ||
899 | |||
900 | case SOUND_MIC_GAIN: | 895 | case SOUND_MIC_GAIN: |
901 | result = value * 20; /* (30/15) *10 */ | 896 | result = value * 5; /* (1/2) * 10 */ |
902 | break; | ||
903 | |||
904 | case SOUND_DECIMATOR_LEFT_GAIN: | ||
905 | case SOUND_DECIMATOR_RIGHT_GAIN: | ||
906 | result = value * 5; /* (1/2) *10 */ | ||
907 | break; | 897 | break; |
908 | 898 | ||
909 | default: | 899 | default: |
910 | result = value; | 900 | result = value; |
911 | break; | 901 | break; |
912 | } | 902 | } |