diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2010-07-27 20:57:33 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2010-07-27 20:57:33 +0000 |
commit | 451138ba74a5914a714214bc09307ea571c56510 (patch) | |
tree | c6028ecc2ea82a745c77e3b82d77db9b2ab0e527 /firmware/drivers/audio | |
parent | 24bde73d1ed1c4a07d0071e7fdf7fd316e719f09 (diff) | |
download | rockbox-451138ba74a5914a714214bc09307ea571c56510.tar.gz rockbox-451138ba74a5914a714214bc09307ea571c56510.zip |
WM8750 - add ALC and NGAT related low level functions (disabled now by default)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27587 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r-- | firmware/drivers/audio/wm8751.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c index 6e37a91ed7..5eb90b0178 100644 --- a/firmware/drivers/audio/wm8751.c +++ b/firmware/drivers/audio/wm8751.c | |||
@@ -98,6 +98,50 @@ static int tone_tenthdb2hw(int value) | |||
98 | return value; | 98 | return value; |
99 | } | 99 | } |
100 | 100 | ||
101 | #if 0 | ||
102 | static int alc_tenthdb2hw(int value) | ||
103 | { | ||
104 | /* -28.5dB - -6dB step 1.5dB - translate -285 - -60 step 15 | ||
105 | to 0 - 15 step 1 | ||
106 | */ | ||
107 | |||
108 | value = 15 - (value + 60)/15; | ||
109 | } | ||
110 | |||
111 | |||
112 | static int alc_hldus2hw(unsigned int value) | ||
113 | { | ||
114 | /* 0000 - 0us | ||
115 | * 0001 - 2670us | ||
116 | * 0010 - 5330us | ||
117 | * | ||
118 | * 1111 - 43691000us | ||
119 | */ | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | static int alc_dcyms2hw(int value) | ||
124 | { | ||
125 | /* 0000 - 24ms | ||
126 | * 0001 - 48ms | ||
127 | * 0010 - 96ms | ||
128 | * | ||
129 | * 1010 or higher 24580ms | ||
130 | */ | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int alc_atkms2hw(int value) | ||
135 | { | ||
136 | /* 0000 - 6ms | ||
137 | * 0001 - 12ms | ||
138 | * 0010 - 24ms | ||
139 | * | ||
140 | * 1010 or higher 6140ms | ||
141 | */ | ||
142 | return 0; | ||
143 | } | ||
144 | #endif | ||
101 | 145 | ||
102 | #ifdef USE_ADAPTIVE_BASS | 146 | #ifdef USE_ADAPTIVE_BASS |
103 | static int adaptivebass2hw(int value) | 147 | static int adaptivebass2hw(int value) |
@@ -110,6 +154,14 @@ static int adaptivebass2hw(int value) | |||
110 | #endif | 154 | #endif |
111 | 155 | ||
112 | #if defined(HAVE_WM8750) | 156 | #if defined(HAVE_WM8750) |
157 | #if 0 | ||
158 | static int ngath_tenthdb2hw(int value) | ||
159 | { | ||
160 | /* -76.5dB - -30dB in 1.5db steps -765 - -300 in 15 steps */ | ||
161 | value = 31 - (value + 300)/15; | ||
162 | return value; | ||
163 | } | ||
164 | #endif | ||
113 | static int recvol2hw(int value) | 165 | static int recvol2hw(int value) |
114 | { | 166 | { |
115 | /* convert tenth of dB of input volume (-172...300) to input register value */ | 167 | /* convert tenth of dB of input volume (-172...300) to input register value */ |
@@ -317,6 +369,72 @@ void audiohw_set_depth_3d(int val) | |||
317 | #endif | 369 | #endif |
318 | 370 | ||
319 | #ifdef HAVE_RECORDING | 371 | #ifdef HAVE_RECORDING |
372 | #if 0 | ||
373 | void audiohw_set_ngath(int ngath, int type, bool enable) | ||
374 | { | ||
375 | /* This function controls Noise gate function | ||
376 | * of the codec. This can only run in conjunction | ||
377 | * with ALC | ||
378 | */ | ||
379 | |||
380 | if(enable) | ||
381 | wmcodec_write(NGAT, NGAT_NGG(type)|NGAT_NGTH(ngath)|NGAT_NGAT); | ||
382 | else | ||
383 | wmcodec_write(NGAT, NGAT_NGG(type)|NGAT_NGTH(ngath_tenthdb2hw(ngath))); | ||
384 | } | ||
385 | |||
386 | |||
387 | void audiohw_set_alc(int level, unsigned int hold, int decay, int attack, bool enable) | ||
388 | { | ||
389 | /* level in thenth of dB -28.5dB - -6dB in 1.5dB steps | ||
390 | * hold time in us 0us - 43691000us | ||
391 | * decay time in ms 24ms - 24580ms | ||
392 | * attack time in ms 6ms - 6140ms | ||
393 | */ | ||
394 | |||
395 | if(enable) | ||
396 | { | ||
397 | wmcodec_write(ALC1, ALC1_ALCSEL_STEREO|ALC1_MAXGAIN(0x07)| | ||
398 | ALC1_ALCL(alc_tenthdb2hw(level))); | ||
399 | wmcodec_write(ALC2, ALC2_ALCZ|ALC2_HLD(alc_hldus2hw(hold))); | ||
400 | wmcodec_write(ALC3, ALC3_DCY(alc_dcyms2hw(decay))| | ||
401 | ALC3_ATK(alc_atkms2hw(attack))); | ||
402 | } | ||
403 | else | ||
404 | { | ||
405 | wmcodec_write(ALC1, ALC1_ALCSEL_DISABLED|ALC1_MAXGAIN(0x07)|ALC1_ALCL(alc_tenthdb2hw(level))); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | void audiohw_set_alc(int level, unsigned int hold, int decay, int attack, bool enable) | ||
410 | { | ||
411 | /* level in thenth of dB -28.5dB - -6dB in 1.5dB steps | ||
412 | * hold time in 15 steps 0ms,2.67ms,5.33ms,...,43691ms | ||
413 | * decay time in 10 steps 24ms,48ms,96ms,...,24580ms | ||
414 | * attack time in 10 steps 6ms,12ms,24ms,...,6140ms | ||
415 | */ | ||
416 | |||
417 | if(enable) | ||
418 | { | ||
419 | wmcodec_write(ALC1, ALC1_ALCSEL_STEREO|ALC1_MAXGAIN(0x07)| | ||
420 | ALC1_ALCL(alc_tenthdb2hw(level))); | ||
421 | wmcodec_write(ALC2, ALC2_ALCZ|ALC2_HLD(hold)); | ||
422 | wmcodec_write(ALC3, ALC3_DCY(decay)| | ||
423 | ALC3_ATK(attack)); | ||
424 | } | ||
425 | else | ||
426 | { | ||
427 | wmcodec_write(ALC1, ALC1_ALCSEL_DISABLED|ALC1_MAXGAIN(0x07)| | ||
428 | ALC1_ALCL(alc_tenthdb2hw(level))); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | void audiohw_set_alc_level(int level) | ||
433 | { | ||
434 | wmcodec_write(ALC1, ALC1_ALCSEL_STEREO|ALC1_MAXGAIN(0x07)| | ||
435 | ALC1_ALCL(alc_tenthdb2hw(level))); | ||
436 | } | ||
437 | #endif | ||
320 | void audiohw_set_recsrc(int source, bool recording) | 438 | void audiohw_set_recsrc(int source, bool recording) |
321 | { | 439 | { |
322 | /* INPUT1 - FM radio | 440 | /* INPUT1 - FM radio |