summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/uda1380.c31
-rw-r--r--firmware/export/audio.h1
-rw-r--r--firmware/export/sound.h4
-rw-r--r--firmware/pcm_record.c3
-rw-r--r--firmware/sound.c20
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 @@
#include "file.h"
#include "buffer.h"
#include "audio.h"
+#include "logf.h"
#include "i2c-coldfire.h"
#include "uda1380.h"
@@ -255,27 +256,37 @@ void uda1380_disable_recording(void)
/**
* Set recording gain and volume
*
- * type: params: ranges:
- * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain
- * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain
- * AUDIO_GAIN_DECIMATOR left & right -128 .. 48 -> -64 .. 24 dB gain
+ * type: params: ranges:
+ * AUDIO_GAIN_MIC: left -128 .. 108 -> -64 .. 54 dB gain
+ * AUDIO_GAIN_LINEIN left & right -128 .. 96 -> -64 .. 48 dB gain
*
* Note: For all types the value 0 gives 0 dB gain.
*/
void uda1380_set_recvol(int left, int right, int type)
{
+ int left_ag, right_ag;
+
switch (type)
{
- case AUDIO_GAIN_MIC:
- uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK) | VGA_GAIN(left));
+ case AUDIO_GAIN_MIC:
+ left_ag = MIN(MAX(0, left / 4), 15);
+ left -= left_ag * 4;
+ uda1380_write_reg(REG_ADC, (uda1380_regs[REG_ADC] & ~VGA_GAIN_MASK)
+ | VGA_GAIN(left_ag));
+ uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(left));
+ logf("Mic: %dA/%dD", left_ag, left);
break;
case AUDIO_GAIN_LINEIN:
- uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right));
- break;
-
- case AUDIO_GAIN_DECIMATOR:
+ left_ag = MIN(MAX(0, left / 6), 8);
+ left -= left_ag * 6;
+ right_ag = MIN(MAX(0, right / 6), 8);
+ right -= right_ag * 6;
+ uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK)
+ | PGA_GAINL(left_ag) | PGA_GAINR(right_ag));
uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right));
+ logf("Line L: %dA/%dD", left_ag, left);
+ logf("Line R: %dA/%dD", right_ag, right);
break;
}
}
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 @@
#define AUDIO_GAIN_LINEIN 0
#define AUDIO_GAIN_MIC 1
-#define AUDIO_GAIN_DECIMATOR 2 /* for UDA1380 */
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 {
SOUND_RIGHT_GAIN,
SOUND_MIC_GAIN,
#endif
-#if defined(HAVE_UDA1380)
- SOUND_DECIMATOR_LEFT_GAIN,
- SOUND_DECIMATOR_RIGHT_GAIN,
-#endif
};
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,
* Note that microphone is mono, only left value is used
* See uda1380_set_recvol() for exact ranges.
*
- * @param type 0=line-in (radio), 1=mic, 2=ADC
+ * @param type 0=line-in (radio), 1=mic
*
*/
void audio_set_recording_gain(int left, int right, int type)
{
- //logf("rcmrec: t=%d l=%d r=%d", type, left, right);
uda1380_set_recvol(left, right, type);
}
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[] = {
[SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL},
[SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL},
#elif defined(HAVE_UDA1380)
- [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
- [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
- [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL},
- [SOUND_DECIMATOR_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL},
- [SOUND_DECIMATOR_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL},
+ [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL},
+ [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL},
+ [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL},
#endif
};
@@ -894,19 +892,11 @@ int sound_val2phys(int setting, int value)
{
case SOUND_LEFT_GAIN:
case SOUND_RIGHT_GAIN:
- result = value * 30; /* (24/8) *10 */
- break;
-
case SOUND_MIC_GAIN:
- result = value * 20; /* (30/15) *10 */
- break;
-
- case SOUND_DECIMATOR_LEFT_GAIN:
- case SOUND_DECIMATOR_RIGHT_GAIN:
- result = value * 5; /* (1/2) *10 */
+ result = value * 5; /* (1/2) * 10 */
break;
- default:
+ default:
result = value;
break;
}