Commit | Line | Data |
---|---|---|
50099328 JB |
1 | /* |
2 | * This file is only included exactly once! | |
3 | * | |
4 | * The tables here are derived from the tas3004 datasheet, | |
5 | * modulo typo corrections and some smoothing... | |
6 | */ | |
7 | ||
8 | #define TAS3004_TREBLE_MIN 0 | |
9 | #define TAS3004_TREBLE_MAX 72 | |
10 | #define TAS3004_BASS_MIN 0 | |
11 | #define TAS3004_BASS_MAX 72 | |
12 | #define TAS3004_TREBLE_ZERO 36 | |
13 | #define TAS3004_BASS_ZERO 36 | |
14 | ||
15 | static u8 tas3004_treble_table[] = { | |
16 | 150, /* -18 dB */ | |
17 | 149, | |
18 | 148, | |
19 | 147, | |
20 | 146, | |
21 | 145, | |
22 | 144, | |
23 | 143, | |
24 | 142, | |
25 | 141, | |
26 | 140, | |
27 | 139, | |
28 | 138, | |
29 | 137, | |
30 | 136, | |
31 | 135, | |
32 | 134, | |
33 | 133, | |
34 | 132, | |
35 | 131, | |
36 | 130, | |
37 | 129, | |
38 | 128, | |
39 | 127, | |
40 | 126, | |
41 | 125, | |
42 | 124, | |
43 | 123, | |
44 | 122, | |
45 | 121, | |
46 | 120, | |
47 | 119, | |
48 | 118, | |
49 | 117, | |
50 | 116, | |
51 | 115, | |
52 | 114, /* 0 dB */ | |
53 | 113, | |
54 | 112, | |
55 | 111, | |
56 | 109, | |
57 | 108, | |
58 | 107, | |
59 | 105, | |
60 | 104, | |
61 | 103, | |
62 | 101, | |
63 | 99, | |
64 | 98, | |
65 | 96, | |
66 | 93, | |
67 | 91, | |
68 | 89, | |
69 | 86, | |
70 | 83, | |
71 | 81, | |
72 | 77, | |
73 | 74, | |
74 | 71, | |
75 | 67, | |
76 | 63, | |
77 | 59, | |
78 | 54, | |
79 | 49, | |
80 | 44, | |
81 | 38, | |
82 | 32, | |
83 | 26, | |
84 | 19, | |
85 | 10, | |
86 | 4, | |
87 | 2, | |
88 | 1, /* +18 dB */ | |
89 | }; | |
90 | ||
91 | static inline u8 tas3004_treble(int idx) | |
92 | { | |
93 | return tas3004_treble_table[idx]; | |
94 | } | |
95 | ||
96 | /* I only save the difference here to the treble table | |
97 | * so that the binary is smaller... | |
98 | * I have also ignored completely differences of | |
99 | * +/- 1 | |
100 | */ | |
101 | static s8 tas3004_bass_diff_to_treble[] = { | |
102 | 2, /* 7 dB, offset 50 */ | |
103 | 2, | |
104 | 2, | |
105 | 2, | |
106 | 2, | |
107 | 1, | |
108 | 2, | |
109 | 2, | |
110 | 2, | |
111 | 3, | |
112 | 4, | |
113 | 4, | |
114 | 5, | |
115 | 6, | |
116 | 7, | |
117 | 8, | |
118 | 9, | |
119 | 10, | |
120 | 11, | |
121 | 14, | |
122 | 13, | |
123 | 8, | |
124 | 1, /* 18 dB */ | |
125 | }; | |
126 | ||
127 | static inline u8 tas3004_bass(int idx) | |
128 | { | |
129 | u8 result = tas3004_treble_table[idx]; | |
130 | ||
131 | if (idx >= 50) | |
132 | result += tas3004_bass_diff_to_treble[idx-50]; | |
133 | return result; | |
134 | } |