DAC Filter controls and hwdep device added.
[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' / 'on' / 'external control'. 'On' means the 
16    bass/treble gain is used, while 'external control' means the 
17    coefficients have been set through the hwdep device (see below).
18
19
20
21 The IIR Filter consists of 2 cascaded biquads. The formula is:
22  /                                \  /                                \
23 |    (N0 + 2*N1*z^-1 + N2*z^-2)    ||    (N3 + 2*N4*z^-1 + N5*z^-2)    |
24 |  ------------------------------  ||  ------------------------------  |
25  \ (32768 - 2*D1*z^-1 - D2*z^-2)  /  \ (32768 - 2*D4*z^-1 - D5*z^-2)  /
26
27 The filter can be controlled through an alsa hwdep device, via 
28 libalsa. A short example follows, note that the data struct must be
29 passed *EXACTLY* as shown:
30
31 #include <stdint.h>
32 #include <alsa/hwdep.h>
33
34 struct _iirfilter_data {
35     int16_t N0, N1, N2, D1, D2;
36     int16_t N3, N4, N5, D4, D5;
37 } iirfilter_data;
38
39 /* Initialize */
40 snd_hwdep *hwdep;
41
42 snd_hwdep_open(&hwdep, "IIR Filter", "w");
43
44 /* To write: */
45 iirfilter_data = {
46         .N0 = 27619, .N1 = -27034, .N2 = 26461, .D1 = 32131, .D2 = -31506,
47     .N3 = 27619, .N4 = -27034, .N5 = 26461, .D4 = 32131, .D5 = -31506
48 };
49
50 snd_hwdep_write(hwdep, (void*)iirfilter_data, sizeof(iirfilter_data));
51
52 /* To read: */
53 snd_hwdep_read(hwdep, (void*)iirfilter_data, sizeof(iirfilter_data));
54
55 /* To enable/disable filtering: */
56 int arg = 1; /* 1 = enable, 0 = disable */
57 snd_hwdep_ioctl(hwdep, 1, &arg);
58
59