diff options
Diffstat (limited to 'firmware/drivers/audio/mas35xx.c')
-rw-r--r-- | firmware/drivers/audio/mas35xx.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/firmware/drivers/audio/mas35xx.c b/firmware/drivers/audio/mas35xx.c index e6cc665109..deb9223187 100644 --- a/firmware/drivers/audio/mas35xx.c +++ b/firmware/drivers/audio/mas35xx.c | |||
@@ -26,36 +26,6 @@ | |||
26 | #include "system.h" /* MAX MIN macros */ | 26 | #include "system.h" /* MAX MIN macros */ |
27 | #include "audiohw.h" | 27 | #include "audiohw.h" |
28 | 28 | ||
29 | const struct sound_settings_info audiohw_settings[] = { | ||
30 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
31 | [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25}, | ||
32 | [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6}, | ||
33 | [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6}, | ||
34 | #elif CONFIG_CODEC == MAS3507D | ||
35 | [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18}, | ||
36 | [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7}, | ||
37 | [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7}, | ||
38 | #endif | ||
39 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
40 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
41 | [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, | ||
42 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
43 | [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0}, | ||
44 | [SOUND_AVC] = {"", 0, 1, -1, 4, 0}, | ||
45 | [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48}, | ||
46 | [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50}, | ||
47 | [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60}, | ||
48 | [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, | ||
49 | [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, | ||
50 | [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, | ||
51 | #endif | ||
52 | #if CONFIG_CODEC == MAS3587F && defined(HAVE_RECORDING) | ||
53 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8}, | ||
54 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8}, | ||
55 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2}, | ||
56 | #endif | ||
57 | }; | ||
58 | |||
59 | int channel_configuration = SOUND_CHAN_STEREO; | 29 | int channel_configuration = SOUND_CHAN_STEREO; |
60 | int stereo_width = 100; | 30 | int stereo_width = 100; |
61 | 31 | ||
@@ -65,7 +35,6 @@ unsigned long loudness_shadow = 0; | |||
65 | unsigned long shadow_io_control_main; | 35 | unsigned long shadow_io_control_main; |
66 | #endif | 36 | #endif |
67 | 37 | ||
68 | |||
69 | static void set_channel_config(void) | 38 | static void set_channel_config(void) |
70 | { | 39 | { |
71 | /* default values: stereo */ | 40 | /* default values: stereo */ |
@@ -185,6 +154,22 @@ void audiohw_set_treble(int val) | |||
185 | #endif | 154 | #endif |
186 | } | 155 | } |
187 | 156 | ||
157 | #if (CONFIG_CODEC == MAS3507D) | ||
158 | /* convert tenth of dB volume (-780..+180) to dac3550 register value */ | ||
159 | static unsigned int tenthdb2reg(int db) | ||
160 | { | ||
161 | if (db < -540) /* 3 dB steps */ | ||
162 | return (db + 780) / 30; | ||
163 | else /* 1.5 dB steps */ | ||
164 | return (db + 660) / 15; | ||
165 | } | ||
166 | |||
167 | void audiohw_set_volume(int vol_l, int vol_r) | ||
168 | { | ||
169 | dac_volume(tenthdb2reg(vol_l), tenthdb2reg(vol_r), false); | ||
170 | } | ||
171 | #endif /* CONFIG_CODEC == MAS3507D */ | ||
172 | |||
188 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 173 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
189 | void audiohw_set_volume(int val) | 174 | void audiohw_set_volume(int val) |
190 | { | 175 | { |
@@ -268,14 +253,32 @@ void audiohw_set_balance(int val) | |||
268 | mas_codec_writereg(MAS_REG_BALANCE, tmp); | 253 | mas_codec_writereg(MAS_REG_BALANCE, tmp); |
269 | } | 254 | } |
270 | 255 | ||
271 | void audiohw_set_pitch(unsigned long val) | 256 | /* This functionality works by telling the decoder that we have another |
257 | crystal frequency than we actually have. It will adjust its internal | ||
258 | parameters and the result is that the audio is played at another pitch. | ||
259 | */ | ||
260 | static int32_t last_pitch = PITCH_SPEED_100; | ||
261 | |||
262 | void audiohw_set_pitch(int32_t val) | ||
272 | { | 263 | { |
273 | mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1); | 264 | if (val == last_pitch) |
265 | return; | ||
266 | |||
267 | /* Calculate the new (bogus) frequency */ | ||
268 | unsigned long reg = 18432 * PITCH_SPEED_100 / val; | ||
269 | mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, ®, 1); | ||
274 | 270 | ||
275 | /* We must tell the MAS that the frequency has changed. | 271 | /* We must tell the MAS that the frequency has changed. |
276 | * This will unfortunately cause a short silence. */ | 272 | * This will unfortunately cause a short silence. */ |
273 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, | ||
274 | &shadow_io_control_main, 1); | ||
275 | |||
276 | last_pitch = val; | ||
277 | } | ||
277 | 278 | ||
278 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); | 279 | int32_t audiohw_get_pitch(void) |
280 | { | ||
281 | return last_pitch; | ||
279 | } | 282 | } |
280 | 283 | ||
281 | #endif /* CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F */ | 284 | #endif /* CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F */ |