Added de-emphasis filter functions and speaker protection.
[aic34-eq] / kernel-2.6.28 / Documentation / sound / alsa / soc / tlv320aic3x.txt
1 The TLV320AIC3X is a powerful four channel low power audio codec family.
2 More information is available at:
3     http://focus.ti.com/docs/prod/folders/print/tlv320aic34.html
4 Datasheet:
5     http://www.ti.com/lit/gpn/tlv320aic34
6
7 The codec driver leverages the codecs effects through alsa controls and a 
8 hwdep device for controlling the hardware fourth-order IIR filter block.
9
10 There's an alsa control, "3D Control - Depth" for depth simulation.
11 The rest of the controls are for the IIR filter:
12
13 1- A control for setting the bass/treble gain, which sets the filter's
14    coefficients to certain precalculated values.
15 2- A control for 'off' / 'Bass/Treble' / 'Custom'. 'Bass/Treble' means
16    the bass/treble gain controls are used, while 'custom' means the 
17    coefficients have been set through the hwdep device (see below).
18 Note: bass/treble controls are not yet implemented
19
20 Filters
21 --------
22 Note: Setting a filter's coeffs automatically turns it off, it needs to
23 be turned on explicitly.
24
25 The De-emphasis filter can only be controlled on the machine driver level.
26 For example for the n900 (rx51.c) it is used as highpass filter for
27 speaker protection. See tlv320aic3x.h, aic3x_deemph_set_* for details.
28
29 The IIR Filter consists of 2 cascaded biquads. The formula is:
30  /                                \  /                                \
31 |    (N0 + 2*N1*z^-1 + N2*z^-2)    ||    (N3 + 2*N4*z^-1 + N5*z^-2)    |
32 |  ------------------------------  ||  ------------------------------  |
33 |  (32768 - 2*D1*z^-1 - D2*z^-2)   ||   (32768 - 2*D4*z^-1 - D5*z^-2)  |
34  \                                /  \                                /
35
36 The filter can be controlled through an alsa hwdep device, via 
37 libasound. A short example follows, note that the data struct must be
38 passed *EXACTLY* as shown. Remember to link against libasound:
39 gcc myapp.c -lasound -o myapp
40
41 -------------------------------EXAMPLE----------------------------------
42 #include <stdint.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <fcntl.h>
46 #include <alsa/asoundlib.h>
47 #include <alsa/hwdep.h>
48
49 struct iirfilter_data {
50     int16_t N0, N1, N2, D1, D2;
51     int16_t N3, N4, N5, D4, D5;
52 };
53
54 int main() {
55     int ret;
56     snd_hwdep_t *hwdep;
57     struct iirfilter_data data = {
58             .N0 = 27619, .N1 = -27034, .N2 = 26461, .D1 = 32131, .D2 = -31506,
59         .N3 = 27619, .N4 = -27034, .N5 = 26461, .D4 = 32131, .D5 = -31506
60     };
61
62 /* Initialize */
63     ret = snd_hwdep_open(&hwdep, "hw:0,0", SND_HWDEP_OPEN_DUPLEX);
64     if(ret != 0) exit(1);
65
66 /* To write: */
67     snd_hwdep_write(hwdep, (void*)&data, sizeof(data));
68
69 /* To read: */
70     snd_hwdep_read(hwdep, (void*)&data, sizeof(data));
71
72 /* To enable/disable filtering: */
73     int arg = 1; /* 1 = enable, 0 = disable */
74     snd_hwdep_ioctl(hwdep, 1, &arg);
75     return 0;
76 }
77 ------------------------------------------------------------------------
78