diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/as3514.c | 36 | ||||
-rw-r--r-- | firmware/export/as3514.h | 6 | ||||
-rw-r--r-- | firmware/sound.c | 2 |
3 files changed, 29 insertions, 15 deletions
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 0fe8d90b11..771275e8fa 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c | |||
@@ -55,16 +55,11 @@ static void as3514_write(int reg, int value) | |||
55 | /* convert tenth of dB volume to master volume register value */ | 55 | /* convert tenth of dB volume to master volume register value */ |
56 | int tenthdb2master(int db) | 56 | int tenthdb2master(int db) |
57 | { | 57 | { |
58 | /* +6 to -40.43dB in 1.5dB steps == 32 levels = 5 bits */ | 58 | /* +6 to -73.5dB in 1.5dB steps == 53 levels */ |
59 | /* 11111 == +6dB (0x1f) = 31) */ | ||
60 | /* 11110 == -4.5dB (0x1e) = 30) */ | ||
61 | /* 00001 == -39dB (0x01) */ | ||
62 | /* 00000 == -40.5dB (0x00) */ | ||
63 | |||
64 | if (db < VOLUME_MIN) { | 59 | if (db < VOLUME_MIN) { |
65 | return 0x0; | 60 | return 0x0; |
66 | } else if (db >= VOLUME_MAX) { | 61 | } else if (db >= VOLUME_MAX) { |
67 | return 0x1f; | 62 | return 0x35; |
68 | } else { | 63 | } else { |
69 | return((db-VOLUME_MIN)/15); /* VOLUME_MIN is negative */ | 64 | return((db-VOLUME_MIN)/15); /* VOLUME_MIN is negative */ |
70 | } | 65 | } |
@@ -147,16 +142,35 @@ void audiohw_enable_output(bool enable) | |||
147 | 142 | ||
148 | int audiohw_set_master_vol(int vol_l, int vol_r) | 143 | int audiohw_set_master_vol(int vol_l, int vol_r) |
149 | { | 144 | { |
150 | vol_l &= 0x1f; | 145 | int hph_r = as3514_regs[HPH_OUT_R] & ~0x1f; |
151 | vol_r &= 0x1f; | 146 | int hph_l = as3514_regs[HPH_OUT_L] & ~0x1f; |
152 | 147 | ||
153 | /* we are controling dac volume instead of headphone volume, | 148 | /* we are controling dac volume instead of headphone volume, |
154 | as the volume is bigger. | 149 | as the volume is bigger. |
155 | HDP: 1.07 dB gain | 150 | HDP: 1.07 dB gain |
156 | DAC: 6 dB gain | 151 | DAC: 6 dB gain |
157 | */ | 152 | */ |
158 | as3514_write(DAC_R, vol_r); | 153 | if(vol_r <= 0x16) |
159 | as3514_write(DAC_L, 0x40 | vol_l); | 154 | { |
155 | as3514_write(DAC_R, vol_r); | ||
156 | as3514_write(HPH_OUT_R, hph_r); /* set 0 */ | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | as3514_write(DAC_R, 0x16); | ||
161 | as3514_write(HPH_OUT_R, hph_r + (vol_r - 0x16)); | ||
162 | } | ||
163 | |||
164 | if(vol_l <= 0x16) | ||
165 | { | ||
166 | as3514_write(DAC_L, 0x40 + vol_l); | ||
167 | as3514_write(HPH_OUT_L, hph_l); /* set 0 */ | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | as3514_write(DAC_L, 0x40 + 0x16); | ||
172 | as3514_write(HPH_OUT_L, hph_l + (vol_l - 0x16)); | ||
173 | } | ||
160 | 174 | ||
161 | return 0; | 175 | return 0; |
162 | } | 176 | } |
diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index e90a8f47ef..5f37fd7fcf 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h | |||
@@ -69,9 +69,9 @@ extern void audiohw_set_monitor(int enable); | |||
69 | #define ADC_0 0x2e | 69 | #define ADC_0 0x2e |
70 | #define ADC_1 0x2f | 70 | #define ADC_1 0x2f |
71 | 71 | ||
72 | /* Headphone volume goes from -40.5 - 6dB */ | 72 | /* Headphone volume goes from -73.5 ... +6dB */ |
73 | #define VOLUME_MIN -405 | 73 | #define VOLUME_MIN -735 |
74 | #define VOLUME_MAX 60 | 74 | #define VOLUME_MAX 60 |
75 | 75 | ||
76 | #ifdef SANSA_E200 | 76 | #ifdef SANSA_E200 |
77 | #define AS3514_I2C_ADDR 0x46 | 77 | #define AS3514_I2C_ADDR 0x46 |
diff --git a/firmware/sound.c b/firmware/sound.c index 2589306290..9c2a8ffb35 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -81,7 +81,7 @@ static const struct sound_settings_info sound_settings_table[] = { | |||
81 | #elif (CONFIG_CPU == PNX0101) | 81 | #elif (CONFIG_CPU == PNX0101) |
82 | [SOUND_VOLUME] = {"dB", 0, 1, -48, 15, 0, sound_set_volume}, | 82 | [SOUND_VOLUME] = {"dB", 0, 1, -48, 15, 0, sound_set_volume}, |
83 | #elif defined(HAVE_AS3514) | 83 | #elif defined(HAVE_AS3514) |
84 | [SOUND_VOLUME] = {"dB", 0, 1, -40, 6, -25, sound_set_volume}, | 84 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, |
85 | #else /* MAS3507D */ | 85 | #else /* MAS3507D */ |
86 | [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, | 86 | [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, |
87 | [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, | 87 | [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, |