1 |
3 |
xianfeng |
/*
|
2 |
|
|
* Driver for Digigram miXart soundcards
|
3 |
|
|
*
|
4 |
|
|
* mixer callbacks
|
5 |
|
|
*
|
6 |
|
|
* Copyright (c) 2003 by Digigram <alsa@digigram.com>
|
7 |
|
|
*
|
8 |
|
|
* This program is free software; you can redistribute it and/or modify
|
9 |
|
|
* it under the terms of the GNU General Public License as published by
|
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
11 |
|
|
* (at your option) any later version.
|
12 |
|
|
*
|
13 |
|
|
* This program is distributed in the hope that it will be useful,
|
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
* GNU General Public License for more details.
|
17 |
|
|
*
|
18 |
|
|
* You should have received a copy of the GNU General Public License
|
19 |
|
|
* along with this program; if not, write to the Free Software
|
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21 |
|
|
*/
|
22 |
|
|
|
23 |
|
|
#include <sound/driver.h>
|
24 |
|
|
#include <linux/time.h>
|
25 |
|
|
#include <linux/interrupt.h>
|
26 |
|
|
#include <linux/init.h>
|
27 |
|
|
#include <linux/mutex.h>
|
28 |
|
|
|
29 |
|
|
#include <sound/core.h>
|
30 |
|
|
#include "mixart.h"
|
31 |
|
|
#include "mixart_core.h"
|
32 |
|
|
#include "mixart_hwdep.h"
|
33 |
|
|
#include <sound/control.h>
|
34 |
|
|
#include <sound/tlv.h>
|
35 |
|
|
#include "mixart_mixer.h"
|
36 |
|
|
|
37 |
|
|
static u32 mixart_analog_level[256] = {
|
38 |
|
|
0xc2c00000, /* [000] -96.0 dB */
|
39 |
|
|
0xc2bf0000, /* [001] -95.5 dB */
|
40 |
|
|
0xc2be0000, /* [002] -95.0 dB */
|
41 |
|
|
0xc2bd0000, /* [003] -94.5 dB */
|
42 |
|
|
0xc2bc0000, /* [004] -94.0 dB */
|
43 |
|
|
0xc2bb0000, /* [005] -93.5 dB */
|
44 |
|
|
0xc2ba0000, /* [006] -93.0 dB */
|
45 |
|
|
0xc2b90000, /* [007] -92.5 dB */
|
46 |
|
|
0xc2b80000, /* [008] -92.0 dB */
|
47 |
|
|
0xc2b70000, /* [009] -91.5 dB */
|
48 |
|
|
0xc2b60000, /* [010] -91.0 dB */
|
49 |
|
|
0xc2b50000, /* [011] -90.5 dB */
|
50 |
|
|
0xc2b40000, /* [012] -90.0 dB */
|
51 |
|
|
0xc2b30000, /* [013] -89.5 dB */
|
52 |
|
|
0xc2b20000, /* [014] -89.0 dB */
|
53 |
|
|
0xc2b10000, /* [015] -88.5 dB */
|
54 |
|
|
0xc2b00000, /* [016] -88.0 dB */
|
55 |
|
|
0xc2af0000, /* [017] -87.5 dB */
|
56 |
|
|
0xc2ae0000, /* [018] -87.0 dB */
|
57 |
|
|
0xc2ad0000, /* [019] -86.5 dB */
|
58 |
|
|
0xc2ac0000, /* [020] -86.0 dB */
|
59 |
|
|
0xc2ab0000, /* [021] -85.5 dB */
|
60 |
|
|
0xc2aa0000, /* [022] -85.0 dB */
|
61 |
|
|
0xc2a90000, /* [023] -84.5 dB */
|
62 |
|
|
0xc2a80000, /* [024] -84.0 dB */
|
63 |
|
|
0xc2a70000, /* [025] -83.5 dB */
|
64 |
|
|
0xc2a60000, /* [026] -83.0 dB */
|
65 |
|
|
0xc2a50000, /* [027] -82.5 dB */
|
66 |
|
|
0xc2a40000, /* [028] -82.0 dB */
|
67 |
|
|
0xc2a30000, /* [029] -81.5 dB */
|
68 |
|
|
0xc2a20000, /* [030] -81.0 dB */
|
69 |
|
|
0xc2a10000, /* [031] -80.5 dB */
|
70 |
|
|
0xc2a00000, /* [032] -80.0 dB */
|
71 |
|
|
0xc29f0000, /* [033] -79.5 dB */
|
72 |
|
|
0xc29e0000, /* [034] -79.0 dB */
|
73 |
|
|
0xc29d0000, /* [035] -78.5 dB */
|
74 |
|
|
0xc29c0000, /* [036] -78.0 dB */
|
75 |
|
|
0xc29b0000, /* [037] -77.5 dB */
|
76 |
|
|
0xc29a0000, /* [038] -77.0 dB */
|
77 |
|
|
0xc2990000, /* [039] -76.5 dB */
|
78 |
|
|
0xc2980000, /* [040] -76.0 dB */
|
79 |
|
|
0xc2970000, /* [041] -75.5 dB */
|
80 |
|
|
0xc2960000, /* [042] -75.0 dB */
|
81 |
|
|
0xc2950000, /* [043] -74.5 dB */
|
82 |
|
|
0xc2940000, /* [044] -74.0 dB */
|
83 |
|
|
0xc2930000, /* [045] -73.5 dB */
|
84 |
|
|
0xc2920000, /* [046] -73.0 dB */
|
85 |
|
|
0xc2910000, /* [047] -72.5 dB */
|
86 |
|
|
0xc2900000, /* [048] -72.0 dB */
|
87 |
|
|
0xc28f0000, /* [049] -71.5 dB */
|
88 |
|
|
0xc28e0000, /* [050] -71.0 dB */
|
89 |
|
|
0xc28d0000, /* [051] -70.5 dB */
|
90 |
|
|
0xc28c0000, /* [052] -70.0 dB */
|
91 |
|
|
0xc28b0000, /* [053] -69.5 dB */
|
92 |
|
|
0xc28a0000, /* [054] -69.0 dB */
|
93 |
|
|
0xc2890000, /* [055] -68.5 dB */
|
94 |
|
|
0xc2880000, /* [056] -68.0 dB */
|
95 |
|
|
0xc2870000, /* [057] -67.5 dB */
|
96 |
|
|
0xc2860000, /* [058] -67.0 dB */
|
97 |
|
|
0xc2850000, /* [059] -66.5 dB */
|
98 |
|
|
0xc2840000, /* [060] -66.0 dB */
|
99 |
|
|
0xc2830000, /* [061] -65.5 dB */
|
100 |
|
|
0xc2820000, /* [062] -65.0 dB */
|
101 |
|
|
0xc2810000, /* [063] -64.5 dB */
|
102 |
|
|
0xc2800000, /* [064] -64.0 dB */
|
103 |
|
|
0xc27e0000, /* [065] -63.5 dB */
|
104 |
|
|
0xc27c0000, /* [066] -63.0 dB */
|
105 |
|
|
0xc27a0000, /* [067] -62.5 dB */
|
106 |
|
|
0xc2780000, /* [068] -62.0 dB */
|
107 |
|
|
0xc2760000, /* [069] -61.5 dB */
|
108 |
|
|
0xc2740000, /* [070] -61.0 dB */
|
109 |
|
|
0xc2720000, /* [071] -60.5 dB */
|
110 |
|
|
0xc2700000, /* [072] -60.0 dB */
|
111 |
|
|
0xc26e0000, /* [073] -59.5 dB */
|
112 |
|
|
0xc26c0000, /* [074] -59.0 dB */
|
113 |
|
|
0xc26a0000, /* [075] -58.5 dB */
|
114 |
|
|
0xc2680000, /* [076] -58.0 dB */
|
115 |
|
|
0xc2660000, /* [077] -57.5 dB */
|
116 |
|
|
0xc2640000, /* [078] -57.0 dB */
|
117 |
|
|
0xc2620000, /* [079] -56.5 dB */
|
118 |
|
|
0xc2600000, /* [080] -56.0 dB */
|
119 |
|
|
0xc25e0000, /* [081] -55.5 dB */
|
120 |
|
|
0xc25c0000, /* [082] -55.0 dB */
|
121 |
|
|
0xc25a0000, /* [083] -54.5 dB */
|
122 |
|
|
0xc2580000, /* [084] -54.0 dB */
|
123 |
|
|
0xc2560000, /* [085] -53.5 dB */
|
124 |
|
|
0xc2540000, /* [086] -53.0 dB */
|
125 |
|
|
0xc2520000, /* [087] -52.5 dB */
|
126 |
|
|
0xc2500000, /* [088] -52.0 dB */
|
127 |
|
|
0xc24e0000, /* [089] -51.5 dB */
|
128 |
|
|
0xc24c0000, /* [090] -51.0 dB */
|
129 |
|
|
0xc24a0000, /* [091] -50.5 dB */
|
130 |
|
|
0xc2480000, /* [092] -50.0 dB */
|
131 |
|
|
0xc2460000, /* [093] -49.5 dB */
|
132 |
|
|
0xc2440000, /* [094] -49.0 dB */
|
133 |
|
|
0xc2420000, /* [095] -48.5 dB */
|
134 |
|
|
0xc2400000, /* [096] -48.0 dB */
|
135 |
|
|
0xc23e0000, /* [097] -47.5 dB */
|
136 |
|
|
0xc23c0000, /* [098] -47.0 dB */
|
137 |
|
|
0xc23a0000, /* [099] -46.5 dB */
|
138 |
|
|
0xc2380000, /* [100] -46.0 dB */
|
139 |
|
|
0xc2360000, /* [101] -45.5 dB */
|
140 |
|
|
0xc2340000, /* [102] -45.0 dB */
|
141 |
|
|
0xc2320000, /* [103] -44.5 dB */
|
142 |
|
|
0xc2300000, /* [104] -44.0 dB */
|
143 |
|
|
0xc22e0000, /* [105] -43.5 dB */
|
144 |
|
|
0xc22c0000, /* [106] -43.0 dB */
|
145 |
|
|
0xc22a0000, /* [107] -42.5 dB */
|
146 |
|
|
0xc2280000, /* [108] -42.0 dB */
|
147 |
|
|
0xc2260000, /* [109] -41.5 dB */
|
148 |
|
|
0xc2240000, /* [110] -41.0 dB */
|
149 |
|
|
0xc2220000, /* [111] -40.5 dB */
|
150 |
|
|
0xc2200000, /* [112] -40.0 dB */
|
151 |
|
|
0xc21e0000, /* [113] -39.5 dB */
|
152 |
|
|
0xc21c0000, /* [114] -39.0 dB */
|
153 |
|
|
0xc21a0000, /* [115] -38.5 dB */
|
154 |
|
|
0xc2180000, /* [116] -38.0 dB */
|
155 |
|
|
0xc2160000, /* [117] -37.5 dB */
|
156 |
|
|
0xc2140000, /* [118] -37.0 dB */
|
157 |
|
|
0xc2120000, /* [119] -36.5 dB */
|
158 |
|
|
0xc2100000, /* [120] -36.0 dB */
|
159 |
|
|
0xc20e0000, /* [121] -35.5 dB */
|
160 |
|
|
0xc20c0000, /* [122] -35.0 dB */
|
161 |
|
|
0xc20a0000, /* [123] -34.5 dB */
|
162 |
|
|
0xc2080000, /* [124] -34.0 dB */
|
163 |
|
|
0xc2060000, /* [125] -33.5 dB */
|
164 |
|
|
0xc2040000, /* [126] -33.0 dB */
|
165 |
|
|
0xc2020000, /* [127] -32.5 dB */
|
166 |
|
|
0xc2000000, /* [128] -32.0 dB */
|
167 |
|
|
0xc1fc0000, /* [129] -31.5 dB */
|
168 |
|
|
0xc1f80000, /* [130] -31.0 dB */
|
169 |
|
|
0xc1f40000, /* [131] -30.5 dB */
|
170 |
|
|
0xc1f00000, /* [132] -30.0 dB */
|
171 |
|
|
0xc1ec0000, /* [133] -29.5 dB */
|
172 |
|
|
0xc1e80000, /* [134] -29.0 dB */
|
173 |
|
|
0xc1e40000, /* [135] -28.5 dB */
|
174 |
|
|
0xc1e00000, /* [136] -28.0 dB */
|
175 |
|
|
0xc1dc0000, /* [137] -27.5 dB */
|
176 |
|
|
0xc1d80000, /* [138] -27.0 dB */
|
177 |
|
|
0xc1d40000, /* [139] -26.5 dB */
|
178 |
|
|
0xc1d00000, /* [140] -26.0 dB */
|
179 |
|
|
0xc1cc0000, /* [141] -25.5 dB */
|
180 |
|
|
0xc1c80000, /* [142] -25.0 dB */
|
181 |
|
|
0xc1c40000, /* [143] -24.5 dB */
|
182 |
|
|
0xc1c00000, /* [144] -24.0 dB */
|
183 |
|
|
0xc1bc0000, /* [145] -23.5 dB */
|
184 |
|
|
0xc1b80000, /* [146] -23.0 dB */
|
185 |
|
|
0xc1b40000, /* [147] -22.5 dB */
|
186 |
|
|
0xc1b00000, /* [148] -22.0 dB */
|
187 |
|
|
0xc1ac0000, /* [149] -21.5 dB */
|
188 |
|
|
0xc1a80000, /* [150] -21.0 dB */
|
189 |
|
|
0xc1a40000, /* [151] -20.5 dB */
|
190 |
|
|
0xc1a00000, /* [152] -20.0 dB */
|
191 |
|
|
0xc19c0000, /* [153] -19.5 dB */
|
192 |
|
|
0xc1980000, /* [154] -19.0 dB */
|
193 |
|
|
0xc1940000, /* [155] -18.5 dB */
|
194 |
|
|
0xc1900000, /* [156] -18.0 dB */
|
195 |
|
|
0xc18c0000, /* [157] -17.5 dB */
|
196 |
|
|
0xc1880000, /* [158] -17.0 dB */
|
197 |
|
|
0xc1840000, /* [159] -16.5 dB */
|
198 |
|
|
0xc1800000, /* [160] -16.0 dB */
|
199 |
|
|
0xc1780000, /* [161] -15.5 dB */
|
200 |
|
|
0xc1700000, /* [162] -15.0 dB */
|
201 |
|
|
0xc1680000, /* [163] -14.5 dB */
|
202 |
|
|
0xc1600000, /* [164] -14.0 dB */
|
203 |
|
|
0xc1580000, /* [165] -13.5 dB */
|
204 |
|
|
0xc1500000, /* [166] -13.0 dB */
|
205 |
|
|
0xc1480000, /* [167] -12.5 dB */
|
206 |
|
|
0xc1400000, /* [168] -12.0 dB */
|
207 |
|
|
0xc1380000, /* [169] -11.5 dB */
|
208 |
|
|
0xc1300000, /* [170] -11.0 dB */
|
209 |
|
|
0xc1280000, /* [171] -10.5 dB */
|
210 |
|
|
0xc1200000, /* [172] -10.0 dB */
|
211 |
|
|
0xc1180000, /* [173] -9.5 dB */
|
212 |
|
|
0xc1100000, /* [174] -9.0 dB */
|
213 |
|
|
0xc1080000, /* [175] -8.5 dB */
|
214 |
|
|
0xc1000000, /* [176] -8.0 dB */
|
215 |
|
|
0xc0f00000, /* [177] -7.5 dB */
|
216 |
|
|
0xc0e00000, /* [178] -7.0 dB */
|
217 |
|
|
0xc0d00000, /* [179] -6.5 dB */
|
218 |
|
|
0xc0c00000, /* [180] -6.0 dB */
|
219 |
|
|
0xc0b00000, /* [181] -5.5 dB */
|
220 |
|
|
0xc0a00000, /* [182] -5.0 dB */
|
221 |
|
|
0xc0900000, /* [183] -4.5 dB */
|
222 |
|
|
0xc0800000, /* [184] -4.0 dB */
|
223 |
|
|
0xc0600000, /* [185] -3.5 dB */
|
224 |
|
|
0xc0400000, /* [186] -3.0 dB */
|
225 |
|
|
0xc0200000, /* [187] -2.5 dB */
|
226 |
|
|
0xc0000000, /* [188] -2.0 dB */
|
227 |
|
|
0xbfc00000, /* [189] -1.5 dB */
|
228 |
|
|
0xbf800000, /* [190] -1.0 dB */
|
229 |
|
|
0xbf000000, /* [191] -0.5 dB */
|
230 |
|
|
0x00000000, /* [192] 0.0 dB */
|
231 |
|
|
0x3f000000, /* [193] 0.5 dB */
|
232 |
|
|
0x3f800000, /* [194] 1.0 dB */
|
233 |
|
|
0x3fc00000, /* [195] 1.5 dB */
|
234 |
|
|
0x40000000, /* [196] 2.0 dB */
|
235 |
|
|
0x40200000, /* [197] 2.5 dB */
|
236 |
|
|
0x40400000, /* [198] 3.0 dB */
|
237 |
|
|
0x40600000, /* [199] 3.5 dB */
|
238 |
|
|
0x40800000, /* [200] 4.0 dB */
|
239 |
|
|
0x40900000, /* [201] 4.5 dB */
|
240 |
|
|
0x40a00000, /* [202] 5.0 dB */
|
241 |
|
|
0x40b00000, /* [203] 5.5 dB */
|
242 |
|
|
0x40c00000, /* [204] 6.0 dB */
|
243 |
|
|
0x40d00000, /* [205] 6.5 dB */
|
244 |
|
|
0x40e00000, /* [206] 7.0 dB */
|
245 |
|
|
0x40f00000, /* [207] 7.5 dB */
|
246 |
|
|
0x41000000, /* [208] 8.0 dB */
|
247 |
|
|
0x41080000, /* [209] 8.5 dB */
|
248 |
|
|
0x41100000, /* [210] 9.0 dB */
|
249 |
|
|
0x41180000, /* [211] 9.5 dB */
|
250 |
|
|
0x41200000, /* [212] 10.0 dB */
|
251 |
|
|
0x41280000, /* [213] 10.5 dB */
|
252 |
|
|
0x41300000, /* [214] 11.0 dB */
|
253 |
|
|
0x41380000, /* [215] 11.5 dB */
|
254 |
|
|
0x41400000, /* [216] 12.0 dB */
|
255 |
|
|
0x41480000, /* [217] 12.5 dB */
|
256 |
|
|
0x41500000, /* [218] 13.0 dB */
|
257 |
|
|
0x41580000, /* [219] 13.5 dB */
|
258 |
|
|
0x41600000, /* [220] 14.0 dB */
|
259 |
|
|
0x41680000, /* [221] 14.5 dB */
|
260 |
|
|
0x41700000, /* [222] 15.0 dB */
|
261 |
|
|
0x41780000, /* [223] 15.5 dB */
|
262 |
|
|
0x41800000, /* [224] 16.0 dB */
|
263 |
|
|
0x41840000, /* [225] 16.5 dB */
|
264 |
|
|
0x41880000, /* [226] 17.0 dB */
|
265 |
|
|
0x418c0000, /* [227] 17.5 dB */
|
266 |
|
|
0x41900000, /* [228] 18.0 dB */
|
267 |
|
|
0x41940000, /* [229] 18.5 dB */
|
268 |
|
|
0x41980000, /* [230] 19.0 dB */
|
269 |
|
|
0x419c0000, /* [231] 19.5 dB */
|
270 |
|
|
0x41a00000, /* [232] 20.0 dB */
|
271 |
|
|
0x41a40000, /* [233] 20.5 dB */
|
272 |
|
|
0x41a80000, /* [234] 21.0 dB */
|
273 |
|
|
0x41ac0000, /* [235] 21.5 dB */
|
274 |
|
|
0x41b00000, /* [236] 22.0 dB */
|
275 |
|
|
0x41b40000, /* [237] 22.5 dB */
|
276 |
|
|
0x41b80000, /* [238] 23.0 dB */
|
277 |
|
|
0x41bc0000, /* [239] 23.5 dB */
|
278 |
|
|
0x41c00000, /* [240] 24.0 dB */
|
279 |
|
|
0x41c40000, /* [241] 24.5 dB */
|
280 |
|
|
0x41c80000, /* [242] 25.0 dB */
|
281 |
|
|
0x41cc0000, /* [243] 25.5 dB */
|
282 |
|
|
0x41d00000, /* [244] 26.0 dB */
|
283 |
|
|
0x41d40000, /* [245] 26.5 dB */
|
284 |
|
|
0x41d80000, /* [246] 27.0 dB */
|
285 |
|
|
0x41dc0000, /* [247] 27.5 dB */
|
286 |
|
|
0x41e00000, /* [248] 28.0 dB */
|
287 |
|
|
0x41e40000, /* [249] 28.5 dB */
|
288 |
|
|
0x41e80000, /* [250] 29.0 dB */
|
289 |
|
|
0x41ec0000, /* [251] 29.5 dB */
|
290 |
|
|
0x41f00000, /* [252] 30.0 dB */
|
291 |
|
|
0x41f40000, /* [253] 30.5 dB */
|
292 |
|
|
0x41f80000, /* [254] 31.0 dB */
|
293 |
|
|
0x41fc0000, /* [255] 31.5 dB */
|
294 |
|
|
};
|
295 |
|
|
|
296 |
|
|
#define MIXART_ANALOG_CAPTURE_LEVEL_MIN 0 /* -96.0 dB + 8.0 dB = -88.0 dB */
|
297 |
|
|
#define MIXART_ANALOG_CAPTURE_LEVEL_MAX 255 /* 31.5 dB + 8.0 dB = 39.5 dB */
|
298 |
|
|
#define MIXART_ANALOG_CAPTURE_ZERO_LEVEL 176 /* -8.0 dB + 8.0 dB = 0.0 dB */
|
299 |
|
|
|
300 |
|
|
#define MIXART_ANALOG_PLAYBACK_LEVEL_MIN 0 /* -96.0 dB + 1.5 dB = -94.5 dB (possible is down to (-114.0+1.5)dB) */
|
301 |
|
|
#define MIXART_ANALOG_PLAYBACK_LEVEL_MAX 192 /* 0.0 dB + 1.5 dB = 1.5 dB */
|
302 |
|
|
#define MIXART_ANALOG_PLAYBACK_ZERO_LEVEL 189 /* -1.5 dB + 1.5 dB = 0.0 dB */
|
303 |
|
|
|
304 |
|
|
static int mixart_update_analog_audio_level(struct snd_mixart* chip, int is_capture)
|
305 |
|
|
{
|
306 |
|
|
int i, err;
|
307 |
|
|
struct mixart_msg request;
|
308 |
|
|
struct mixart_io_level io_level;
|
309 |
|
|
struct mixart_return_uid resp;
|
310 |
|
|
|
311 |
|
|
memset(&io_level, 0, sizeof(io_level));
|
312 |
|
|
io_level.channel = -1; /* left and right */
|
313 |
|
|
|
314 |
|
|
for(i=0; i<2; i++) {
|
315 |
|
|
if(is_capture) {
|
316 |
|
|
io_level.level[i].analog_level = mixart_analog_level[chip->analog_capture_volume[i]];
|
317 |
|
|
} else {
|
318 |
|
|
if(chip->analog_playback_active[i])
|
319 |
|
|
io_level.level[i].analog_level = mixart_analog_level[chip->analog_playback_volume[i]];
|
320 |
|
|
else
|
321 |
|
|
io_level.level[i].analog_level = mixart_analog_level[MIXART_ANALOG_PLAYBACK_LEVEL_MIN];
|
322 |
|
|
}
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
if(is_capture) request.uid = chip->uid_in_analog_physio;
|
326 |
|
|
else request.uid = chip->uid_out_analog_physio;
|
327 |
|
|
request.message_id = MSG_PHYSICALIO_SET_LEVEL;
|
328 |
|
|
request.data = &io_level;
|
329 |
|
|
request.size = sizeof(io_level);
|
330 |
|
|
|
331 |
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
|
332 |
|
|
if((err<0) || (resp.error_code)) {
|
333 |
|
|
snd_printk(KERN_DEBUG "error MSG_PHYSICALIO_SET_LEVEL card(%d) is_capture(%d) error_code(%x)\n", chip->chip_idx, is_capture, resp.error_code);
|
334 |
|
|
return -EINVAL;
|
335 |
|
|
}
|
336 |
|
|
return 0;
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
/*
|
340 |
|
|
* analog level control
|
341 |
|
|
*/
|
342 |
|
|
static int mixart_analog_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
343 |
|
|
{
|
344 |
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
345 |
|
|
uinfo->count = 2;
|
346 |
|
|
if(kcontrol->private_value == 0) { /* playback */
|
347 |
|
|
uinfo->value.integer.min = MIXART_ANALOG_PLAYBACK_LEVEL_MIN; /* -96 dB */
|
348 |
|
|
uinfo->value.integer.max = MIXART_ANALOG_PLAYBACK_LEVEL_MAX; /* 0 dB */
|
349 |
|
|
} else { /* capture */
|
350 |
|
|
uinfo->value.integer.min = MIXART_ANALOG_CAPTURE_LEVEL_MIN; /* -96 dB */
|
351 |
|
|
uinfo->value.integer.max = MIXART_ANALOG_CAPTURE_LEVEL_MAX; /* 31.5 dB */
|
352 |
|
|
}
|
353 |
|
|
return 0;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
static int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
357 |
|
|
{
|
358 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
359 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
360 |
|
|
if(kcontrol->private_value == 0) { /* playback */
|
361 |
|
|
ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
|
362 |
|
|
ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
|
363 |
|
|
} else { /* capture */
|
364 |
|
|
ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
|
365 |
|
|
ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
|
366 |
|
|
}
|
367 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
368 |
|
|
return 0;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
372 |
|
|
{
|
373 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
374 |
|
|
int changed = 0;
|
375 |
|
|
int is_capture, i;
|
376 |
|
|
|
377 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
378 |
|
|
is_capture = (kcontrol->private_value != 0);
|
379 |
|
|
for(i=0; i<2; i++) {
|
380 |
|
|
int new_volume = ucontrol->value.integer.value[i];
|
381 |
|
|
int* stored_volume = is_capture ? &chip->analog_capture_volume[i] : &chip->analog_playback_volume[i];
|
382 |
|
|
if(*stored_volume != new_volume) {
|
383 |
|
|
*stored_volume = new_volume;
|
384 |
|
|
changed = 1;
|
385 |
|
|
}
|
386 |
|
|
}
|
387 |
|
|
if(changed) mixart_update_analog_audio_level(chip, is_capture);
|
388 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
389 |
|
|
return changed;
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
static const DECLARE_TLV_DB_SCALE(db_scale_analog, -9600, 50, 0);
|
393 |
|
|
|
394 |
|
|
static struct snd_kcontrol_new mixart_control_analog_level = {
|
395 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
396 |
|
|
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
397 |
|
|
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
|
398 |
|
|
/* name will be filled later */
|
399 |
|
|
.info = mixart_analog_vol_info,
|
400 |
|
|
.get = mixart_analog_vol_get,
|
401 |
|
|
.put = mixart_analog_vol_put,
|
402 |
|
|
.tlv = { .p = db_scale_analog },
|
403 |
|
|
};
|
404 |
|
|
|
405 |
|
|
/* shared */
|
406 |
|
|
#define mixart_sw_info snd_ctl_boolean_stereo_info
|
407 |
|
|
|
408 |
|
|
static int mixart_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
409 |
|
|
{
|
410 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
411 |
|
|
|
412 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
413 |
|
|
ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
|
414 |
|
|
ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
|
415 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
416 |
|
|
return 0;
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
static int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
420 |
|
|
{
|
421 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
422 |
|
|
int i, changed = 0;
|
423 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
424 |
|
|
for(i=0; i<2; i++) {
|
425 |
|
|
if(chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) {
|
426 |
|
|
chip->analog_playback_active[i] = ucontrol->value.integer.value[i];
|
427 |
|
|
changed = 1;
|
428 |
|
|
}
|
429 |
|
|
}
|
430 |
|
|
if(changed) mixart_update_analog_audio_level(chip, 0); /* update playback levels */
|
431 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
432 |
|
|
return changed;
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
static struct snd_kcontrol_new mixart_control_output_switch = {
|
436 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
437 |
|
|
.name = "Master Playback Switch",
|
438 |
|
|
.info = mixart_sw_info, /* shared */
|
439 |
|
|
.get = mixart_audio_sw_get,
|
440 |
|
|
.put = mixart_audio_sw_put
|
441 |
|
|
};
|
442 |
|
|
|
443 |
|
|
static u32 mixart_digital_level[256] = {
|
444 |
|
|
0x00000000, /* [000] = 0.00e+000 = mute if <= -109.5dB */
|
445 |
|
|
0x366e1c7a, /* [001] = 3.55e-006 = pow(10.0, 0.05 * -109.0dB) */
|
446 |
|
|
0x367c3860, /* [002] = 3.76e-006 = pow(10.0, 0.05 * -108.5dB) */
|
447 |
|
|
0x36859525, /* [003] = 3.98e-006 = pow(10.0, 0.05 * -108.0dB) */
|
448 |
|
|
0x368d7f74, /* [004] = 4.22e-006 = pow(10.0, 0.05 * -107.5dB) */
|
449 |
|
|
0x3695e1d4, /* [005] = 4.47e-006 = pow(10.0, 0.05 * -107.0dB) */
|
450 |
|
|
0x369ec362, /* [006] = 4.73e-006 = pow(10.0, 0.05 * -106.5dB) */
|
451 |
|
|
0x36a82ba8, /* [007] = 5.01e-006 = pow(10.0, 0.05 * -106.0dB) */
|
452 |
|
|
0x36b222a0, /* [008] = 5.31e-006 = pow(10.0, 0.05 * -105.5dB) */
|
453 |
|
|
0x36bcb0c1, /* [009] = 5.62e-006 = pow(10.0, 0.05 * -105.0dB) */
|
454 |
|
|
0x36c7defd, /* [010] = 5.96e-006 = pow(10.0, 0.05 * -104.5dB) */
|
455 |
|
|
0x36d3b6d3, /* [011] = 6.31e-006 = pow(10.0, 0.05 * -104.0dB) */
|
456 |
|
|
0x36e0424e, /* [012] = 6.68e-006 = pow(10.0, 0.05 * -103.5dB) */
|
457 |
|
|
0x36ed8c14, /* [013] = 7.08e-006 = pow(10.0, 0.05 * -103.0dB) */
|
458 |
|
|
0x36fb9f6c, /* [014] = 7.50e-006 = pow(10.0, 0.05 * -102.5dB) */
|
459 |
|
|
0x37054423, /* [015] = 7.94e-006 = pow(10.0, 0.05 * -102.0dB) */
|
460 |
|
|
0x370d29a5, /* [016] = 8.41e-006 = pow(10.0, 0.05 * -101.5dB) */
|
461 |
|
|
0x371586f0, /* [017] = 8.91e-006 = pow(10.0, 0.05 * -101.0dB) */
|
462 |
|
|
0x371e631b, /* [018] = 9.44e-006 = pow(10.0, 0.05 * -100.5dB) */
|
463 |
|
|
0x3727c5ac, /* [019] = 1.00e-005 = pow(10.0, 0.05 * -100.0dB) */
|
464 |
|
|
0x3731b69a, /* [020] = 1.06e-005 = pow(10.0, 0.05 * -99.5dB) */
|
465 |
|
|
0x373c3e53, /* [021] = 1.12e-005 = pow(10.0, 0.05 * -99.0dB) */
|
466 |
|
|
0x374765c8, /* [022] = 1.19e-005 = pow(10.0, 0.05 * -98.5dB) */
|
467 |
|
|
0x3753366f, /* [023] = 1.26e-005 = pow(10.0, 0.05 * -98.0dB) */
|
468 |
|
|
0x375fba4f, /* [024] = 1.33e-005 = pow(10.0, 0.05 * -97.5dB) */
|
469 |
|
|
0x376cfc07, /* [025] = 1.41e-005 = pow(10.0, 0.05 * -97.0dB) */
|
470 |
|
|
0x377b06d5, /* [026] = 1.50e-005 = pow(10.0, 0.05 * -96.5dB) */
|
471 |
|
|
0x3784f352, /* [027] = 1.58e-005 = pow(10.0, 0.05 * -96.0dB) */
|
472 |
|
|
0x378cd40b, /* [028] = 1.68e-005 = pow(10.0, 0.05 * -95.5dB) */
|
473 |
|
|
0x37952c42, /* [029] = 1.78e-005 = pow(10.0, 0.05 * -95.0dB) */
|
474 |
|
|
0x379e030e, /* [030] = 1.88e-005 = pow(10.0, 0.05 * -94.5dB) */
|
475 |
|
|
0x37a75fef, /* [031] = 2.00e-005 = pow(10.0, 0.05 * -94.0dB) */
|
476 |
|
|
0x37b14ad5, /* [032] = 2.11e-005 = pow(10.0, 0.05 * -93.5dB) */
|
477 |
|
|
0x37bbcc2c, /* [033] = 2.24e-005 = pow(10.0, 0.05 * -93.0dB) */
|
478 |
|
|
0x37c6ecdd, /* [034] = 2.37e-005 = pow(10.0, 0.05 * -92.5dB) */
|
479 |
|
|
0x37d2b65a, /* [035] = 2.51e-005 = pow(10.0, 0.05 * -92.0dB) */
|
480 |
|
|
0x37df32a3, /* [036] = 2.66e-005 = pow(10.0, 0.05 * -91.5dB) */
|
481 |
|
|
0x37ec6c50, /* [037] = 2.82e-005 = pow(10.0, 0.05 * -91.0dB) */
|
482 |
|
|
0x37fa6e9b, /* [038] = 2.99e-005 = pow(10.0, 0.05 * -90.5dB) */
|
483 |
|
|
0x3804a2b3, /* [039] = 3.16e-005 = pow(10.0, 0.05 * -90.0dB) */
|
484 |
|
|
0x380c7ea4, /* [040] = 3.35e-005 = pow(10.0, 0.05 * -89.5dB) */
|
485 |
|
|
0x3814d1cc, /* [041] = 3.55e-005 = pow(10.0, 0.05 * -89.0dB) */
|
486 |
|
|
0x381da33c, /* [042] = 3.76e-005 = pow(10.0, 0.05 * -88.5dB) */
|
487 |
|
|
0x3826fa6f, /* [043] = 3.98e-005 = pow(10.0, 0.05 * -88.0dB) */
|
488 |
|
|
0x3830df51, /* [044] = 4.22e-005 = pow(10.0, 0.05 * -87.5dB) */
|
489 |
|
|
0x383b5a49, /* [045] = 4.47e-005 = pow(10.0, 0.05 * -87.0dB) */
|
490 |
|
|
0x3846743b, /* [046] = 4.73e-005 = pow(10.0, 0.05 * -86.5dB) */
|
491 |
|
|
0x38523692, /* [047] = 5.01e-005 = pow(10.0, 0.05 * -86.0dB) */
|
492 |
|
|
0x385eab48, /* [048] = 5.31e-005 = pow(10.0, 0.05 * -85.5dB) */
|
493 |
|
|
0x386bdcf1, /* [049] = 5.62e-005 = pow(10.0, 0.05 * -85.0dB) */
|
494 |
|
|
0x3879d6bc, /* [050] = 5.96e-005 = pow(10.0, 0.05 * -84.5dB) */
|
495 |
|
|
0x38845244, /* [051] = 6.31e-005 = pow(10.0, 0.05 * -84.0dB) */
|
496 |
|
|
0x388c2971, /* [052] = 6.68e-005 = pow(10.0, 0.05 * -83.5dB) */
|
497 |
|
|
0x3894778d, /* [053] = 7.08e-005 = pow(10.0, 0.05 * -83.0dB) */
|
498 |
|
|
0x389d43a4, /* [054] = 7.50e-005 = pow(10.0, 0.05 * -82.5dB) */
|
499 |
|
|
0x38a6952c, /* [055] = 7.94e-005 = pow(10.0, 0.05 * -82.0dB) */
|
500 |
|
|
0x38b0740f, /* [056] = 8.41e-005 = pow(10.0, 0.05 * -81.5dB) */
|
501 |
|
|
0x38bae8ac, /* [057] = 8.91e-005 = pow(10.0, 0.05 * -81.0dB) */
|
502 |
|
|
0x38c5fbe2, /* [058] = 9.44e-005 = pow(10.0, 0.05 * -80.5dB) */
|
503 |
|
|
0x38d1b717, /* [059] = 1.00e-004 = pow(10.0, 0.05 * -80.0dB) */
|
504 |
|
|
0x38de2440, /* [060] = 1.06e-004 = pow(10.0, 0.05 * -79.5dB) */
|
505 |
|
|
0x38eb4de8, /* [061] = 1.12e-004 = pow(10.0, 0.05 * -79.0dB) */
|
506 |
|
|
0x38f93f3a, /* [062] = 1.19e-004 = pow(10.0, 0.05 * -78.5dB) */
|
507 |
|
|
0x39040206, /* [063] = 1.26e-004 = pow(10.0, 0.05 * -78.0dB) */
|
508 |
|
|
0x390bd472, /* [064] = 1.33e-004 = pow(10.0, 0.05 * -77.5dB) */
|
509 |
|
|
0x39141d84, /* [065] = 1.41e-004 = pow(10.0, 0.05 * -77.0dB) */
|
510 |
|
|
0x391ce445, /* [066] = 1.50e-004 = pow(10.0, 0.05 * -76.5dB) */
|
511 |
|
|
0x39263027, /* [067] = 1.58e-004 = pow(10.0, 0.05 * -76.0dB) */
|
512 |
|
|
0x3930090d, /* [068] = 1.68e-004 = pow(10.0, 0.05 * -75.5dB) */
|
513 |
|
|
0x393a7753, /* [069] = 1.78e-004 = pow(10.0, 0.05 * -75.0dB) */
|
514 |
|
|
0x394583d2, /* [070] = 1.88e-004 = pow(10.0, 0.05 * -74.5dB) */
|
515 |
|
|
0x395137ea, /* [071] = 2.00e-004 = pow(10.0, 0.05 * -74.0dB) */
|
516 |
|
|
0x395d9d8a, /* [072] = 2.11e-004 = pow(10.0, 0.05 * -73.5dB) */
|
517 |
|
|
0x396abf37, /* [073] = 2.24e-004 = pow(10.0, 0.05 * -73.0dB) */
|
518 |
|
|
0x3978a814, /* [074] = 2.37e-004 = pow(10.0, 0.05 * -72.5dB) */
|
519 |
|
|
0x3983b1f8, /* [075] = 2.51e-004 = pow(10.0, 0.05 * -72.0dB) */
|
520 |
|
|
0x398b7fa6, /* [076] = 2.66e-004 = pow(10.0, 0.05 * -71.5dB) */
|
521 |
|
|
0x3993c3b2, /* [077] = 2.82e-004 = pow(10.0, 0.05 * -71.0dB) */
|
522 |
|
|
0x399c8521, /* [078] = 2.99e-004 = pow(10.0, 0.05 * -70.5dB) */
|
523 |
|
|
0x39a5cb5f, /* [079] = 3.16e-004 = pow(10.0, 0.05 * -70.0dB) */
|
524 |
|
|
0x39af9e4d, /* [080] = 3.35e-004 = pow(10.0, 0.05 * -69.5dB) */
|
525 |
|
|
0x39ba063f, /* [081] = 3.55e-004 = pow(10.0, 0.05 * -69.0dB) */
|
526 |
|
|
0x39c50c0b, /* [082] = 3.76e-004 = pow(10.0, 0.05 * -68.5dB) */
|
527 |
|
|
0x39d0b90a, /* [083] = 3.98e-004 = pow(10.0, 0.05 * -68.0dB) */
|
528 |
|
|
0x39dd1726, /* [084] = 4.22e-004 = pow(10.0, 0.05 * -67.5dB) */
|
529 |
|
|
0x39ea30db, /* [085] = 4.47e-004 = pow(10.0, 0.05 * -67.0dB) */
|
530 |
|
|
0x39f81149, /* [086] = 4.73e-004 = pow(10.0, 0.05 * -66.5dB) */
|
531 |
|
|
0x3a03621b, /* [087] = 5.01e-004 = pow(10.0, 0.05 * -66.0dB) */
|
532 |
|
|
0x3a0b2b0d, /* [088] = 5.31e-004 = pow(10.0, 0.05 * -65.5dB) */
|
533 |
|
|
0x3a136a16, /* [089] = 5.62e-004 = pow(10.0, 0.05 * -65.0dB) */
|
534 |
|
|
0x3a1c2636, /* [090] = 5.96e-004 = pow(10.0, 0.05 * -64.5dB) */
|
535 |
|
|
0x3a2566d5, /* [091] = 6.31e-004 = pow(10.0, 0.05 * -64.0dB) */
|
536 |
|
|
0x3a2f33cd, /* [092] = 6.68e-004 = pow(10.0, 0.05 * -63.5dB) */
|
537 |
|
|
0x3a399570, /* [093] = 7.08e-004 = pow(10.0, 0.05 * -63.0dB) */
|
538 |
|
|
0x3a44948c, /* [094] = 7.50e-004 = pow(10.0, 0.05 * -62.5dB) */
|
539 |
|
|
0x3a503a77, /* [095] = 7.94e-004 = pow(10.0, 0.05 * -62.0dB) */
|
540 |
|
|
0x3a5c9112, /* [096] = 8.41e-004 = pow(10.0, 0.05 * -61.5dB) */
|
541 |
|
|
0x3a69a2d7, /* [097] = 8.91e-004 = pow(10.0, 0.05 * -61.0dB) */
|
542 |
|
|
0x3a777ada, /* [098] = 9.44e-004 = pow(10.0, 0.05 * -60.5dB) */
|
543 |
|
|
0x3a83126f, /* [099] = 1.00e-003 = pow(10.0, 0.05 * -60.0dB) */
|
544 |
|
|
0x3a8ad6a8, /* [100] = 1.06e-003 = pow(10.0, 0.05 * -59.5dB) */
|
545 |
|
|
0x3a9310b1, /* [101] = 1.12e-003 = pow(10.0, 0.05 * -59.0dB) */
|
546 |
|
|
0x3a9bc784, /* [102] = 1.19e-003 = pow(10.0, 0.05 * -58.5dB) */
|
547 |
|
|
0x3aa50287, /* [103] = 1.26e-003 = pow(10.0, 0.05 * -58.0dB) */
|
548 |
|
|
0x3aaec98e, /* [104] = 1.33e-003 = pow(10.0, 0.05 * -57.5dB) */
|
549 |
|
|
0x3ab924e5, /* [105] = 1.41e-003 = pow(10.0, 0.05 * -57.0dB) */
|
550 |
|
|
0x3ac41d56, /* [106] = 1.50e-003 = pow(10.0, 0.05 * -56.5dB) */
|
551 |
|
|
0x3acfbc31, /* [107] = 1.58e-003 = pow(10.0, 0.05 * -56.0dB) */
|
552 |
|
|
0x3adc0b51, /* [108] = 1.68e-003 = pow(10.0, 0.05 * -55.5dB) */
|
553 |
|
|
0x3ae91528, /* [109] = 1.78e-003 = pow(10.0, 0.05 * -55.0dB) */
|
554 |
|
|
0x3af6e4c6, /* [110] = 1.88e-003 = pow(10.0, 0.05 * -54.5dB) */
|
555 |
|
|
0x3b02c2f2, /* [111] = 2.00e-003 = pow(10.0, 0.05 * -54.0dB) */
|
556 |
|
|
0x3b0a8276, /* [112] = 2.11e-003 = pow(10.0, 0.05 * -53.5dB) */
|
557 |
|
|
0x3b12b782, /* [113] = 2.24e-003 = pow(10.0, 0.05 * -53.0dB) */
|
558 |
|
|
0x3b1b690d, /* [114] = 2.37e-003 = pow(10.0, 0.05 * -52.5dB) */
|
559 |
|
|
0x3b249e76, /* [115] = 2.51e-003 = pow(10.0, 0.05 * -52.0dB) */
|
560 |
|
|
0x3b2e5f8f, /* [116] = 2.66e-003 = pow(10.0, 0.05 * -51.5dB) */
|
561 |
|
|
0x3b38b49f, /* [117] = 2.82e-003 = pow(10.0, 0.05 * -51.0dB) */
|
562 |
|
|
0x3b43a669, /* [118] = 2.99e-003 = pow(10.0, 0.05 * -50.5dB) */
|
563 |
|
|
0x3b4f3e37, /* [119] = 3.16e-003 = pow(10.0, 0.05 * -50.0dB) */
|
564 |
|
|
0x3b5b85e0, /* [120] = 3.35e-003 = pow(10.0, 0.05 * -49.5dB) */
|
565 |
|
|
0x3b6887cf, /* [121] = 3.55e-003 = pow(10.0, 0.05 * -49.0dB) */
|
566 |
|
|
0x3b764f0e, /* [122] = 3.76e-003 = pow(10.0, 0.05 * -48.5dB) */
|
567 |
|
|
0x3b8273a6, /* [123] = 3.98e-003 = pow(10.0, 0.05 * -48.0dB) */
|
568 |
|
|
0x3b8a2e77, /* [124] = 4.22e-003 = pow(10.0, 0.05 * -47.5dB) */
|
569 |
|
|
0x3b925e89, /* [125] = 4.47e-003 = pow(10.0, 0.05 * -47.0dB) */
|
570 |
|
|
0x3b9b0ace, /* [126] = 4.73e-003 = pow(10.0, 0.05 * -46.5dB) */
|
571 |
|
|
0x3ba43aa2, /* [127] = 5.01e-003 = pow(10.0, 0.05 * -46.0dB) */
|
572 |
|
|
0x3badf5d1, /* [128] = 5.31e-003 = pow(10.0, 0.05 * -45.5dB) */
|
573 |
|
|
0x3bb8449c, /* [129] = 5.62e-003 = pow(10.0, 0.05 * -45.0dB) */
|
574 |
|
|
0x3bc32fc3, /* [130] = 5.96e-003 = pow(10.0, 0.05 * -44.5dB) */
|
575 |
|
|
0x3bcec08a, /* [131] = 6.31e-003 = pow(10.0, 0.05 * -44.0dB) */
|
576 |
|
|
0x3bdb00c0, /* [132] = 6.68e-003 = pow(10.0, 0.05 * -43.5dB) */
|
577 |
|
|
0x3be7facc, /* [133] = 7.08e-003 = pow(10.0, 0.05 * -43.0dB) */
|
578 |
|
|
0x3bf5b9b0, /* [134] = 7.50e-003 = pow(10.0, 0.05 * -42.5dB) */
|
579 |
|
|
0x3c02248a, /* [135] = 7.94e-003 = pow(10.0, 0.05 * -42.0dB) */
|
580 |
|
|
0x3c09daac, /* [136] = 8.41e-003 = pow(10.0, 0.05 * -41.5dB) */
|
581 |
|
|
0x3c1205c6, /* [137] = 8.91e-003 = pow(10.0, 0.05 * -41.0dB) */
|
582 |
|
|
0x3c1aacc8, /* [138] = 9.44e-003 = pow(10.0, 0.05 * -40.5dB) */
|
583 |
|
|
0x3c23d70a, /* [139] = 1.00e-002 = pow(10.0, 0.05 * -40.0dB) */
|
584 |
|
|
0x3c2d8c52, /* [140] = 1.06e-002 = pow(10.0, 0.05 * -39.5dB) */
|
585 |
|
|
0x3c37d4dd, /* [141] = 1.12e-002 = pow(10.0, 0.05 * -39.0dB) */
|
586 |
|
|
0x3c42b965, /* [142] = 1.19e-002 = pow(10.0, 0.05 * -38.5dB) */
|
587 |
|
|
0x3c4e4329, /* [143] = 1.26e-002 = pow(10.0, 0.05 * -38.0dB) */
|
588 |
|
|
0x3c5a7bf1, /* [144] = 1.33e-002 = pow(10.0, 0.05 * -37.5dB) */
|
589 |
|
|
0x3c676e1e, /* [145] = 1.41e-002 = pow(10.0, 0.05 * -37.0dB) */
|
590 |
|
|
0x3c7524ac, /* [146] = 1.50e-002 = pow(10.0, 0.05 * -36.5dB) */
|
591 |
|
|
0x3c81d59f, /* [147] = 1.58e-002 = pow(10.0, 0.05 * -36.0dB) */
|
592 |
|
|
0x3c898712, /* [148] = 1.68e-002 = pow(10.0, 0.05 * -35.5dB) */
|
593 |
|
|
0x3c91ad39, /* [149] = 1.78e-002 = pow(10.0, 0.05 * -35.0dB) */
|
594 |
|
|
0x3c9a4efc, /* [150] = 1.88e-002 = pow(10.0, 0.05 * -34.5dB) */
|
595 |
|
|
0x3ca373af, /* [151] = 2.00e-002 = pow(10.0, 0.05 * -34.0dB) */
|
596 |
|
|
0x3cad2314, /* [152] = 2.11e-002 = pow(10.0, 0.05 * -33.5dB) */
|
597 |
|
|
0x3cb76563, /* [153] = 2.24e-002 = pow(10.0, 0.05 * -33.0dB) */
|
598 |
|
|
0x3cc24350, /* [154] = 2.37e-002 = pow(10.0, 0.05 * -32.5dB) */
|
599 |
|
|
0x3ccdc614, /* [155] = 2.51e-002 = pow(10.0, 0.05 * -32.0dB) */
|
600 |
|
|
0x3cd9f773, /* [156] = 2.66e-002 = pow(10.0, 0.05 * -31.5dB) */
|
601 |
|
|
0x3ce6e1c6, /* [157] = 2.82e-002 = pow(10.0, 0.05 * -31.0dB) */
|
602 |
|
|
0x3cf49003, /* [158] = 2.99e-002 = pow(10.0, 0.05 * -30.5dB) */
|
603 |
|
|
0x3d0186e2, /* [159] = 3.16e-002 = pow(10.0, 0.05 * -30.0dB) */
|
604 |
|
|
0x3d0933ac, /* [160] = 3.35e-002 = pow(10.0, 0.05 * -29.5dB) */
|
605 |
|
|
0x3d1154e1, /* [161] = 3.55e-002 = pow(10.0, 0.05 * -29.0dB) */
|
606 |
|
|
0x3d19f169, /* [162] = 3.76e-002 = pow(10.0, 0.05 * -28.5dB) */
|
607 |
|
|
0x3d231090, /* [163] = 3.98e-002 = pow(10.0, 0.05 * -28.0dB) */
|
608 |
|
|
0x3d2cba15, /* [164] = 4.22e-002 = pow(10.0, 0.05 * -27.5dB) */
|
609 |
|
|
0x3d36f62b, /* [165] = 4.47e-002 = pow(10.0, 0.05 * -27.0dB) */
|
610 |
|
|
0x3d41cd81, /* [166] = 4.73e-002 = pow(10.0, 0.05 * -26.5dB) */
|
611 |
|
|
0x3d4d494a, /* [167] = 5.01e-002 = pow(10.0, 0.05 * -26.0dB) */
|
612 |
|
|
0x3d597345, /* [168] = 5.31e-002 = pow(10.0, 0.05 * -25.5dB) */
|
613 |
|
|
0x3d6655c3, /* [169] = 5.62e-002 = pow(10.0, 0.05 * -25.0dB) */
|
614 |
|
|
0x3d73fbb4, /* [170] = 5.96e-002 = pow(10.0, 0.05 * -24.5dB) */
|
615 |
|
|
0x3d813856, /* [171] = 6.31e-002 = pow(10.0, 0.05 * -24.0dB) */
|
616 |
|
|
0x3d88e078, /* [172] = 6.68e-002 = pow(10.0, 0.05 * -23.5dB) */
|
617 |
|
|
0x3d90fcbf, /* [173] = 7.08e-002 = pow(10.0, 0.05 * -23.0dB) */
|
618 |
|
|
0x3d99940e, /* [174] = 7.50e-002 = pow(10.0, 0.05 * -22.5dB) */
|
619 |
|
|
0x3da2adad, /* [175] = 7.94e-002 = pow(10.0, 0.05 * -22.0dB) */
|
620 |
|
|
0x3dac5156, /* [176] = 8.41e-002 = pow(10.0, 0.05 * -21.5dB) */
|
621 |
|
|
0x3db68738, /* [177] = 8.91e-002 = pow(10.0, 0.05 * -21.0dB) */
|
622 |
|
|
0x3dc157fb, /* [178] = 9.44e-002 = pow(10.0, 0.05 * -20.5dB) */
|
623 |
|
|
0x3dcccccd, /* [179] = 1.00e-001 = pow(10.0, 0.05 * -20.0dB) */
|
624 |
|
|
0x3dd8ef67, /* [180] = 1.06e-001 = pow(10.0, 0.05 * -19.5dB) */
|
625 |
|
|
0x3de5ca15, /* [181] = 1.12e-001 = pow(10.0, 0.05 * -19.0dB) */
|
626 |
|
|
0x3df367bf, /* [182] = 1.19e-001 = pow(10.0, 0.05 * -18.5dB) */
|
627 |
|
|
0x3e00e9f9, /* [183] = 1.26e-001 = pow(10.0, 0.05 * -18.0dB) */
|
628 |
|
|
0x3e088d77, /* [184] = 1.33e-001 = pow(10.0, 0.05 * -17.5dB) */
|
629 |
|
|
0x3e10a4d3, /* [185] = 1.41e-001 = pow(10.0, 0.05 * -17.0dB) */
|
630 |
|
|
0x3e1936ec, /* [186] = 1.50e-001 = pow(10.0, 0.05 * -16.5dB) */
|
631 |
|
|
0x3e224b06, /* [187] = 1.58e-001 = pow(10.0, 0.05 * -16.0dB) */
|
632 |
|
|
0x3e2be8d7, /* [188] = 1.68e-001 = pow(10.0, 0.05 * -15.5dB) */
|
633 |
|
|
0x3e361887, /* [189] = 1.78e-001 = pow(10.0, 0.05 * -15.0dB) */
|
634 |
|
|
0x3e40e2bb, /* [190] = 1.88e-001 = pow(10.0, 0.05 * -14.5dB) */
|
635 |
|
|
0x3e4c509b, /* [191] = 2.00e-001 = pow(10.0, 0.05 * -14.0dB) */
|
636 |
|
|
0x3e586bd9, /* [192] = 2.11e-001 = pow(10.0, 0.05 * -13.5dB) */
|
637 |
|
|
0x3e653ebb, /* [193] = 2.24e-001 = pow(10.0, 0.05 * -13.0dB) */
|
638 |
|
|
0x3e72d424, /* [194] = 2.37e-001 = pow(10.0, 0.05 * -12.5dB) */
|
639 |
|
|
0x3e809bcc, /* [195] = 2.51e-001 = pow(10.0, 0.05 * -12.0dB) */
|
640 |
|
|
0x3e883aa8, /* [196] = 2.66e-001 = pow(10.0, 0.05 * -11.5dB) */
|
641 |
|
|
0x3e904d1c, /* [197] = 2.82e-001 = pow(10.0, 0.05 * -11.0dB) */
|
642 |
|
|
0x3e98da02, /* [198] = 2.99e-001 = pow(10.0, 0.05 * -10.5dB) */
|
643 |
|
|
0x3ea1e89b, /* [199] = 3.16e-001 = pow(10.0, 0.05 * -10.0dB) */
|
644 |
|
|
0x3eab8097, /* [200] = 3.35e-001 = pow(10.0, 0.05 * -9.5dB) */
|
645 |
|
|
0x3eb5aa1a, /* [201] = 3.55e-001 = pow(10.0, 0.05 * -9.0dB) */
|
646 |
|
|
0x3ec06dc3, /* [202] = 3.76e-001 = pow(10.0, 0.05 * -8.5dB) */
|
647 |
|
|
0x3ecbd4b4, /* [203] = 3.98e-001 = pow(10.0, 0.05 * -8.0dB) */
|
648 |
|
|
0x3ed7e89b, /* [204] = 4.22e-001 = pow(10.0, 0.05 * -7.5dB) */
|
649 |
|
|
0x3ee4b3b6, /* [205] = 4.47e-001 = pow(10.0, 0.05 * -7.0dB) */
|
650 |
|
|
0x3ef240e2, /* [206] = 4.73e-001 = pow(10.0, 0.05 * -6.5dB) */
|
651 |
|
|
0x3f004dce, /* [207] = 5.01e-001 = pow(10.0, 0.05 * -6.0dB) */
|
652 |
|
|
0x3f07e80b, /* [208] = 5.31e-001 = pow(10.0, 0.05 * -5.5dB) */
|
653 |
|
|
0x3f0ff59a, /* [209] = 5.62e-001 = pow(10.0, 0.05 * -5.0dB) */
|
654 |
|
|
0x3f187d50, /* [210] = 5.96e-001 = pow(10.0, 0.05 * -4.5dB) */
|
655 |
|
|
0x3f21866c, /* [211] = 6.31e-001 = pow(10.0, 0.05 * -4.0dB) */
|
656 |
|
|
0x3f2b1896, /* [212] = 6.68e-001 = pow(10.0, 0.05 * -3.5dB) */
|
657 |
|
|
0x3f353bef, /* [213] = 7.08e-001 = pow(10.0, 0.05 * -3.0dB) */
|
658 |
|
|
0x3f3ff911, /* [214] = 7.50e-001 = pow(10.0, 0.05 * -2.5dB) */
|
659 |
|
|
0x3f4b5918, /* [215] = 7.94e-001 = pow(10.0, 0.05 * -2.0dB) */
|
660 |
|
|
0x3f5765ac, /* [216] = 8.41e-001 = pow(10.0, 0.05 * -1.5dB) */
|
661 |
|
|
0x3f642905, /* [217] = 8.91e-001 = pow(10.0, 0.05 * -1.0dB) */
|
662 |
|
|
0x3f71adf9, /* [218] = 9.44e-001 = pow(10.0, 0.05 * -0.5dB) */
|
663 |
|
|
0x3f800000, /* [219] = 1.00e+000 = pow(10.0, 0.05 * 0.0dB) */
|
664 |
|
|
0x3f8795a0, /* [220] = 1.06e+000 = pow(10.0, 0.05 * 0.5dB) */
|
665 |
|
|
0x3f8f9e4d, /* [221] = 1.12e+000 = pow(10.0, 0.05 * 1.0dB) */
|
666 |
|
|
0x3f9820d7, /* [222] = 1.19e+000 = pow(10.0, 0.05 * 1.5dB) */
|
667 |
|
|
0x3fa12478, /* [223] = 1.26e+000 = pow(10.0, 0.05 * 2.0dB) */
|
668 |
|
|
0x3faab0d5, /* [224] = 1.33e+000 = pow(10.0, 0.05 * 2.5dB) */
|
669 |
|
|
0x3fb4ce08, /* [225] = 1.41e+000 = pow(10.0, 0.05 * 3.0dB) */
|
670 |
|
|
0x3fbf84a6, /* [226] = 1.50e+000 = pow(10.0, 0.05 * 3.5dB) */
|
671 |
|
|
0x3fcaddc8, /* [227] = 1.58e+000 = pow(10.0, 0.05 * 4.0dB) */
|
672 |
|
|
0x3fd6e30d, /* [228] = 1.68e+000 = pow(10.0, 0.05 * 4.5dB) */
|
673 |
|
|
0x3fe39ea9, /* [229] = 1.78e+000 = pow(10.0, 0.05 * 5.0dB) */
|
674 |
|
|
0x3ff11b6a, /* [230] = 1.88e+000 = pow(10.0, 0.05 * 5.5dB) */
|
675 |
|
|
0x3fff64c1, /* [231] = 2.00e+000 = pow(10.0, 0.05 * 6.0dB) */
|
676 |
|
|
0x40074368, /* [232] = 2.11e+000 = pow(10.0, 0.05 * 6.5dB) */
|
677 |
|
|
0x400f4735, /* [233] = 2.24e+000 = pow(10.0, 0.05 * 7.0dB) */
|
678 |
|
|
0x4017c496, /* [234] = 2.37e+000 = pow(10.0, 0.05 * 7.5dB) */
|
679 |
|
|
0x4020c2bf, /* [235] = 2.51e+000 = pow(10.0, 0.05 * 8.0dB) */
|
680 |
|
|
0x402a4952, /* [236] = 2.66e+000 = pow(10.0, 0.05 * 8.5dB) */
|
681 |
|
|
0x40346063, /* [237] = 2.82e+000 = pow(10.0, 0.05 * 9.0dB) */
|
682 |
|
|
0x403f1082, /* [238] = 2.99e+000 = pow(10.0, 0.05 * 9.5dB) */
|
683 |
|
|
0x404a62c2, /* [239] = 3.16e+000 = pow(10.0, 0.05 * 10.0dB) */
|
684 |
|
|
0x405660bd, /* [240] = 3.35e+000 = pow(10.0, 0.05 * 10.5dB) */
|
685 |
|
|
0x406314a0, /* [241] = 3.55e+000 = pow(10.0, 0.05 * 11.0dB) */
|
686 |
|
|
0x40708933, /* [242] = 3.76e+000 = pow(10.0, 0.05 * 11.5dB) */
|
687 |
|
|
0x407ec9e1, /* [243] = 3.98e+000 = pow(10.0, 0.05 * 12.0dB) */
|
688 |
|
|
0x4086f161, /* [244] = 4.22e+000 = pow(10.0, 0.05 * 12.5dB) */
|
689 |
|
|
0x408ef052, /* [245] = 4.47e+000 = pow(10.0, 0.05 * 13.0dB) */
|
690 |
|
|
0x4097688d, /* [246] = 4.73e+000 = pow(10.0, 0.05 * 13.5dB) */
|
691 |
|
|
0x40a06142, /* [247] = 5.01e+000 = pow(10.0, 0.05 * 14.0dB) */
|
692 |
|
|
0x40a9e20e, /* [248] = 5.31e+000 = pow(10.0, 0.05 * 14.5dB) */
|
693 |
|
|
0x40b3f300, /* [249] = 5.62e+000 = pow(10.0, 0.05 * 15.0dB) */
|
694 |
|
|
0x40be9ca5, /* [250] = 5.96e+000 = pow(10.0, 0.05 * 15.5dB) */
|
695 |
|
|
0x40c9e807, /* [251] = 6.31e+000 = pow(10.0, 0.05 * 16.0dB) */
|
696 |
|
|
0x40d5debc, /* [252] = 6.68e+000 = pow(10.0, 0.05 * 16.5dB) */
|
697 |
|
|
0x40e28aeb, /* [253] = 7.08e+000 = pow(10.0, 0.05 * 17.0dB) */
|
698 |
|
|
0x40eff755, /* [254] = 7.50e+000 = pow(10.0, 0.05 * 17.5dB) */
|
699 |
|
|
0x40fe2f5e, /* [255] = 7.94e+000 = pow(10.0, 0.05 * 18.0dB) */
|
700 |
|
|
};
|
701 |
|
|
|
702 |
|
|
#define MIXART_DIGITAL_LEVEL_MIN 0 /* -109.5 dB */
|
703 |
|
|
#define MIXART_DIGITAL_LEVEL_MAX 255 /* 18.0 dB */
|
704 |
|
|
#define MIXART_DIGITAL_ZERO_LEVEL 219 /* 0.0 dB */
|
705 |
|
|
|
706 |
|
|
|
707 |
|
|
int mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int idx)
|
708 |
|
|
{
|
709 |
|
|
int err, i;
|
710 |
|
|
int volume[2];
|
711 |
|
|
struct mixart_msg request;
|
712 |
|
|
struct mixart_set_out_stream_level_req set_level;
|
713 |
|
|
u32 status;
|
714 |
|
|
struct mixart_pipe *pipe;
|
715 |
|
|
|
716 |
|
|
memset(&set_level, 0, sizeof(set_level));
|
717 |
|
|
set_level.nb_of_stream = 1;
|
718 |
|
|
set_level.stream_level.desc.stream_idx = idx;
|
719 |
|
|
|
720 |
|
|
if(is_aes) {
|
721 |
|
|
pipe = &chip->pipe_out_dig; /* AES playback */
|
722 |
|
|
idx += MIXART_PLAYBACK_STREAMS;
|
723 |
|
|
} else {
|
724 |
|
|
pipe = &chip->pipe_out_ana; /* analog playback */
|
725 |
|
|
}
|
726 |
|
|
|
727 |
|
|
/* only when pipe exists ! */
|
728 |
|
|
if(pipe->status == PIPE_UNDEFINED)
|
729 |
|
|
return 0;
|
730 |
|
|
|
731 |
|
|
set_level.stream_level.desc.uid_pipe = pipe->group_uid;
|
732 |
|
|
|
733 |
|
|
for(i=0; i<2; i++) {
|
734 |
|
|
if(chip->digital_playback_active[idx][i])
|
735 |
|
|
volume[i] = chip->digital_playback_volume[idx][i];
|
736 |
|
|
else
|
737 |
|
|
volume[i] = MIXART_DIGITAL_LEVEL_MIN;
|
738 |
|
|
}
|
739 |
|
|
|
740 |
|
|
set_level.stream_level.out_level.valid_mask1 = MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1 | MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2;
|
741 |
|
|
set_level.stream_level.out_level.left_to_out1_level = mixart_digital_level[volume[0]];
|
742 |
|
|
set_level.stream_level.out_level.right_to_out2_level = mixart_digital_level[volume[1]];
|
743 |
|
|
|
744 |
|
|
request.message_id = MSG_STREAM_SET_OUT_STREAM_LEVEL;
|
745 |
|
|
request.uid = (struct mixart_uid){0,0};
|
746 |
|
|
request.data = &set_level;
|
747 |
|
|
request.size = sizeof(set_level);
|
748 |
|
|
|
749 |
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
|
750 |
|
|
if((err<0) || status) {
|
751 |
|
|
snd_printk(KERN_DEBUG "error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n", chip->chip_idx, status);
|
752 |
|
|
return -EINVAL;
|
753 |
|
|
}
|
754 |
|
|
return 0;
|
755 |
|
|
}
|
756 |
|
|
|
757 |
|
|
int mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes)
|
758 |
|
|
{
|
759 |
|
|
int err, i, idx;
|
760 |
|
|
struct mixart_pipe *pipe;
|
761 |
|
|
struct mixart_msg request;
|
762 |
|
|
struct mixart_set_in_audio_level_req set_level;
|
763 |
|
|
u32 status;
|
764 |
|
|
|
765 |
|
|
if(is_aes) {
|
766 |
|
|
idx = 1;
|
767 |
|
|
pipe = &chip->pipe_in_dig;
|
768 |
|
|
} else {
|
769 |
|
|
idx = 0;
|
770 |
|
|
pipe = &chip->pipe_in_ana;
|
771 |
|
|
}
|
772 |
|
|
|
773 |
|
|
/* only when pipe exists ! */
|
774 |
|
|
if(pipe->status == PIPE_UNDEFINED)
|
775 |
|
|
return 0;
|
776 |
|
|
|
777 |
|
|
memset(&set_level, 0, sizeof(set_level));
|
778 |
|
|
set_level.audio_count = 2;
|
779 |
|
|
set_level.level[0].connector = pipe->uid_left_connector;
|
780 |
|
|
set_level.level[1].connector = pipe->uid_right_connector;
|
781 |
|
|
|
782 |
|
|
for(i=0; i<2; i++) {
|
783 |
|
|
set_level.level[i].valid_mask1 = MIXART_AUDIO_LEVEL_DIGITAL_MASK;
|
784 |
|
|
set_level.level[i].digital_level = mixart_digital_level[chip->digital_capture_volume[idx][i]];
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
request.message_id = MSG_STREAM_SET_IN_AUDIO_LEVEL;
|
788 |
|
|
request.uid = (struct mixart_uid){0,0};
|
789 |
|
|
request.data = &set_level;
|
790 |
|
|
request.size = sizeof(set_level);
|
791 |
|
|
|
792 |
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
|
793 |
|
|
if((err<0) || status) {
|
794 |
|
|
snd_printk(KERN_DEBUG "error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n", chip->chip_idx, status);
|
795 |
|
|
return -EINVAL;
|
796 |
|
|
}
|
797 |
|
|
return 0;
|
798 |
|
|
}
|
799 |
|
|
|
800 |
|
|
|
801 |
|
|
/* shared */
|
802 |
|
|
static int mixart_digital_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
803 |
|
|
{
|
804 |
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
805 |
|
|
uinfo->count = 2;
|
806 |
|
|
uinfo->value.integer.min = MIXART_DIGITAL_LEVEL_MIN; /* -109.5 dB */
|
807 |
|
|
uinfo->value.integer.max = MIXART_DIGITAL_LEVEL_MAX; /* 18.0 dB */
|
808 |
|
|
return 0;
|
809 |
|
|
}
|
810 |
|
|
|
811 |
|
|
#define MIXART_VOL_REC_MASK 1
|
812 |
|
|
#define MIXART_VOL_AES_MASK 2
|
813 |
|
|
|
814 |
|
|
static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
815 |
|
|
{
|
816 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
817 |
|
|
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
818 |
|
|
int *stored_volume;
|
819 |
|
|
int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK;
|
820 |
|
|
int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
|
821 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
822 |
|
|
if(is_capture) {
|
823 |
|
|
if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */
|
824 |
|
|
else stored_volume = chip->digital_capture_volume[0]; /* analog capture */
|
825 |
|
|
} else {
|
826 |
|
|
snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
|
827 |
|
|
if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */
|
828 |
|
|
else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */
|
829 |
|
|
}
|
830 |
|
|
ucontrol->value.integer.value[0] = stored_volume[0];
|
831 |
|
|
ucontrol->value.integer.value[1] = stored_volume[1];
|
832 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
833 |
|
|
return 0;
|
834 |
|
|
}
|
835 |
|
|
|
836 |
|
|
static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
837 |
|
|
{
|
838 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
839 |
|
|
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
840 |
|
|
int changed = 0;
|
841 |
|
|
int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK;
|
842 |
|
|
int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
|
843 |
|
|
int* stored_volume;
|
844 |
|
|
int i;
|
845 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
846 |
|
|
if(is_capture) {
|
847 |
|
|
if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */
|
848 |
|
|
else stored_volume = chip->digital_capture_volume[0]; /* analog capture */
|
849 |
|
|
} else {
|
850 |
|
|
snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
|
851 |
|
|
if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */
|
852 |
|
|
else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */
|
853 |
|
|
}
|
854 |
|
|
for(i=0; i<2; i++) {
|
855 |
|
|
if(stored_volume[i] != ucontrol->value.integer.value[i]) {
|
856 |
|
|
stored_volume[i] = ucontrol->value.integer.value[i];
|
857 |
|
|
changed = 1;
|
858 |
|
|
}
|
859 |
|
|
}
|
860 |
|
|
if(changed) {
|
861 |
|
|
if(is_capture) mixart_update_capture_stream_level(chip, is_aes);
|
862 |
|
|
else mixart_update_playback_stream_level(chip, is_aes, idx);
|
863 |
|
|
}
|
864 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
865 |
|
|
return changed;
|
866 |
|
|
}
|
867 |
|
|
|
868 |
|
|
static const DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
|
869 |
|
|
|
870 |
|
|
static struct snd_kcontrol_new snd_mixart_pcm_vol =
|
871 |
|
|
{
|
872 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
873 |
|
|
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
874 |
|
|
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
|
875 |
|
|
/* name will be filled later */
|
876 |
|
|
/* count will be filled later */
|
877 |
|
|
.info = mixart_digital_vol_info, /* shared */
|
878 |
|
|
.get = mixart_pcm_vol_get,
|
879 |
|
|
.put = mixart_pcm_vol_put,
|
880 |
|
|
.tlv = { .p = db_scale_digital },
|
881 |
|
|
};
|
882 |
|
|
|
883 |
|
|
|
884 |
|
|
static int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
885 |
|
|
{
|
886 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
887 |
|
|
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
888 |
|
|
snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
|
889 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
890 |
|
|
if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */
|
891 |
|
|
idx += MIXART_PLAYBACK_STREAMS;
|
892 |
|
|
ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
|
893 |
|
|
ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
|
894 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
895 |
|
|
return 0;
|
896 |
|
|
}
|
897 |
|
|
|
898 |
|
|
static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
899 |
|
|
{
|
900 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
901 |
|
|
int changed = 0;
|
902 |
|
|
int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
|
903 |
|
|
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
904 |
|
|
int i, j;
|
905 |
|
|
snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
|
906 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
907 |
|
|
j = idx;
|
908 |
|
|
if(is_aes) j += MIXART_PLAYBACK_STREAMS;
|
909 |
|
|
for(i=0; i<2; i++) {
|
910 |
|
|
if(chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) {
|
911 |
|
|
chip->digital_playback_active[j][i] = ucontrol->value.integer.value[i];
|
912 |
|
|
changed = 1;
|
913 |
|
|
}
|
914 |
|
|
}
|
915 |
|
|
if(changed) mixart_update_playback_stream_level(chip, is_aes, idx);
|
916 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
917 |
|
|
return changed;
|
918 |
|
|
}
|
919 |
|
|
|
920 |
|
|
static struct snd_kcontrol_new mixart_control_pcm_switch = {
|
921 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
922 |
|
|
/* name will be filled later */
|
923 |
|
|
.count = MIXART_PLAYBACK_STREAMS,
|
924 |
|
|
.info = mixart_sw_info, /* shared */
|
925 |
|
|
.get = mixart_pcm_sw_get,
|
926 |
|
|
.put = mixart_pcm_sw_put
|
927 |
|
|
};
|
928 |
|
|
|
929 |
|
|
static int mixart_update_monitoring(struct snd_mixart* chip, int channel)
|
930 |
|
|
{
|
931 |
|
|
int err;
|
932 |
|
|
struct mixart_msg request;
|
933 |
|
|
struct mixart_set_out_audio_level audio_level;
|
934 |
|
|
u32 resp;
|
935 |
|
|
|
936 |
|
|
if(chip->pipe_out_ana.status == PIPE_UNDEFINED)
|
937 |
|
|
return -EINVAL; /* no pipe defined */
|
938 |
|
|
|
939 |
|
|
if(!channel) request.uid = chip->pipe_out_ana.uid_left_connector;
|
940 |
|
|
else request.uid = chip->pipe_out_ana.uid_right_connector;
|
941 |
|
|
request.message_id = MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL;
|
942 |
|
|
request.data = &audio_level;
|
943 |
|
|
request.size = sizeof(audio_level);
|
944 |
|
|
|
945 |
|
|
memset(&audio_level, 0, sizeof(audio_level));
|
946 |
|
|
audio_level.valid_mask1 = MIXART_AUDIO_LEVEL_MONITOR_MASK | MIXART_AUDIO_LEVEL_MUTE_M1_MASK;
|
947 |
|
|
audio_level.monitor_level = mixart_digital_level[chip->monitoring_volume[channel!=0]];
|
948 |
|
|
audio_level.monitor_mute1 = !chip->monitoring_active[channel!=0];
|
949 |
|
|
|
950 |
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
|
951 |
|
|
if((err<0) || resp) {
|
952 |
|
|
snd_printk(KERN_DEBUG "error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n", chip->chip_idx, resp);
|
953 |
|
|
return -EINVAL;
|
954 |
|
|
}
|
955 |
|
|
return 0;
|
956 |
|
|
}
|
957 |
|
|
|
958 |
|
|
/*
|
959 |
|
|
* monitoring level control
|
960 |
|
|
*/
|
961 |
|
|
|
962 |
|
|
static int mixart_monitor_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
963 |
|
|
{
|
964 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
965 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
966 |
|
|
ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
|
967 |
|
|
ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
|
968 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
969 |
|
|
return 0;
|
970 |
|
|
}
|
971 |
|
|
|
972 |
|
|
static int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
973 |
|
|
{
|
974 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
975 |
|
|
int changed = 0;
|
976 |
|
|
int i;
|
977 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
978 |
|
|
for(i=0; i<2; i++) {
|
979 |
|
|
if(chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) {
|
980 |
|
|
chip->monitoring_volume[i] = ucontrol->value.integer.value[i];
|
981 |
|
|
mixart_update_monitoring(chip, i);
|
982 |
|
|
changed = 1;
|
983 |
|
|
}
|
984 |
|
|
}
|
985 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
986 |
|
|
return changed;
|
987 |
|
|
}
|
988 |
|
|
|
989 |
|
|
static struct snd_kcontrol_new mixart_control_monitor_vol = {
|
990 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
991 |
|
|
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
992 |
|
|
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
|
993 |
|
|
.name = "Monitoring Volume",
|
994 |
|
|
.info = mixart_digital_vol_info, /* shared */
|
995 |
|
|
.get = mixart_monitor_vol_get,
|
996 |
|
|
.put = mixart_monitor_vol_put,
|
997 |
|
|
.tlv = { .p = db_scale_digital },
|
998 |
|
|
};
|
999 |
|
|
|
1000 |
|
|
/*
|
1001 |
|
|
* monitoring switch control
|
1002 |
|
|
*/
|
1003 |
|
|
|
1004 |
|
|
static int mixart_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
1005 |
|
|
{
|
1006 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
1007 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
1008 |
|
|
ucontrol->value.integer.value[0] = chip->monitoring_active[0];
|
1009 |
|
|
ucontrol->value.integer.value[1] = chip->monitoring_active[1];
|
1010 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
1011 |
|
|
return 0;
|
1012 |
|
|
}
|
1013 |
|
|
|
1014 |
|
|
static int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
1015 |
|
|
{
|
1016 |
|
|
struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
|
1017 |
|
|
int changed = 0;
|
1018 |
|
|
int i;
|
1019 |
|
|
mutex_lock(&chip->mgr->mixer_mutex);
|
1020 |
|
|
for(i=0; i<2; i++) {
|
1021 |
|
|
if(chip->monitoring_active[i] != ucontrol->value.integer.value[i]) {
|
1022 |
|
|
chip->monitoring_active[i] = ucontrol->value.integer.value[i];
|
1023 |
|
|
changed |= (1<<i); /* mask 0x01 ans 0x02 */
|
1024 |
|
|
}
|
1025 |
|
|
}
|
1026 |
|
|
if(changed) {
|
1027 |
|
|
/* allocate or release resources for monitoring */
|
1028 |
|
|
int allocate = chip->monitoring_active[0] || chip->monitoring_active[1];
|
1029 |
|
|
if(allocate) {
|
1030 |
|
|
snd_mixart_add_ref_pipe( chip, MIXART_PCM_ANALOG, 0, 1); /* allocate the playback pipe for monitoring */
|
1031 |
|
|
snd_mixart_add_ref_pipe( chip, MIXART_PCM_ANALOG, 1, 1); /* allocate the capture pipe for monitoring */
|
1032 |
|
|
}
|
1033 |
|
|
if(changed & 0x01) mixart_update_monitoring(chip, 0);
|
1034 |
|
|
if(changed & 0x02) mixart_update_monitoring(chip, 1);
|
1035 |
|
|
if(!allocate) {
|
1036 |
|
|
snd_mixart_kill_ref_pipe( chip->mgr, &chip->pipe_in_ana, 1); /* release the capture pipe for monitoring */
|
1037 |
|
|
snd_mixart_kill_ref_pipe( chip->mgr, &chip->pipe_out_ana, 1); /* release the playback pipe for monitoring */
|
1038 |
|
|
}
|
1039 |
|
|
}
|
1040 |
|
|
|
1041 |
|
|
mutex_unlock(&chip->mgr->mixer_mutex);
|
1042 |
|
|
return (changed != 0);
|
1043 |
|
|
}
|
1044 |
|
|
|
1045 |
|
|
static struct snd_kcontrol_new mixart_control_monitor_sw = {
|
1046 |
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
1047 |
|
|
.name = "Monitoring Switch",
|
1048 |
|
|
.info = mixart_sw_info, /* shared */
|
1049 |
|
|
.get = mixart_monitor_sw_get,
|
1050 |
|
|
.put = mixart_monitor_sw_put
|
1051 |
|
|
};
|
1052 |
|
|
|
1053 |
|
|
|
1054 |
|
|
static void mixart_reset_audio_levels(struct snd_mixart *chip)
|
1055 |
|
|
{
|
1056 |
|
|
/* analog volumes can be set even if there is no pipe */
|
1057 |
|
|
mixart_update_analog_audio_level(chip, 0);
|
1058 |
|
|
/* analog levels for capture only on the first two chips */
|
1059 |
|
|
if(chip->chip_idx < 2) {
|
1060 |
|
|
mixart_update_analog_audio_level(chip, 1);
|
1061 |
|
|
}
|
1062 |
|
|
return;
|
1063 |
|
|
}
|
1064 |
|
|
|
1065 |
|
|
|
1066 |
|
|
int snd_mixart_create_mixer(struct mixart_mgr *mgr)
|
1067 |
|
|
{
|
1068 |
|
|
struct snd_mixart *chip;
|
1069 |
|
|
int err, i;
|
1070 |
|
|
|
1071 |
|
|
mutex_init(&mgr->mixer_mutex); /* can be in another place */
|
1072 |
|
|
|
1073 |
|
|
for(i=0; i<mgr->num_cards; i++) {
|
1074 |
|
|
struct snd_kcontrol_new temp;
|
1075 |
|
|
chip = mgr->chip[i];
|
1076 |
|
|
|
1077 |
|
|
/* analog output level control */
|
1078 |
|
|
temp = mixart_control_analog_level;
|
1079 |
|
|
temp.name = "Master Playback Volume";
|
1080 |
|
|
temp.private_value = 0; /* playback */
|
1081 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1082 |
|
|
return err;
|
1083 |
|
|
/* output mute controls */
|
1084 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_output_switch, chip))) < 0)
|
1085 |
|
|
return err;
|
1086 |
|
|
|
1087 |
|
|
/* analog input level control only on first two chips !*/
|
1088 |
|
|
if(i<2) {
|
1089 |
|
|
temp = mixart_control_analog_level;
|
1090 |
|
|
temp.name = "Master Capture Volume";
|
1091 |
|
|
temp.private_value = 1; /* capture */
|
1092 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1093 |
|
|
return err;
|
1094 |
|
|
}
|
1095 |
|
|
|
1096 |
|
|
temp = snd_mixart_pcm_vol;
|
1097 |
|
|
temp.name = "PCM Playback Volume";
|
1098 |
|
|
temp.count = MIXART_PLAYBACK_STREAMS;
|
1099 |
|
|
temp.private_value = 0; /* playback analog */
|
1100 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1101 |
|
|
return err;
|
1102 |
|
|
|
1103 |
|
|
temp.name = "PCM Capture Volume";
|
1104 |
|
|
temp.count = 1;
|
1105 |
|
|
temp.private_value = MIXART_VOL_REC_MASK; /* capture analog */
|
1106 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1107 |
|
|
return err;
|
1108 |
|
|
|
1109 |
|
|
if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
|
1110 |
|
|
temp.name = "AES Playback Volume";
|
1111 |
|
|
temp.count = MIXART_PLAYBACK_STREAMS;
|
1112 |
|
|
temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
|
1113 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1114 |
|
|
return err;
|
1115 |
|
|
|
1116 |
|
|
temp.name = "AES Capture Volume";
|
1117 |
|
|
temp.count = 0;
|
1118 |
|
|
temp.private_value = MIXART_VOL_REC_MASK | MIXART_VOL_AES_MASK; /* capture AES/EBU */
|
1119 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1120 |
|
|
return err;
|
1121 |
|
|
}
|
1122 |
|
|
temp = mixart_control_pcm_switch;
|
1123 |
|
|
temp.name = "PCM Playback Switch";
|
1124 |
|
|
temp.private_value = 0; /* playback analog */
|
1125 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1126 |
|
|
return err;
|
1127 |
|
|
|
1128 |
|
|
if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
|
1129 |
|
|
temp.name = "AES Playback Switch";
|
1130 |
|
|
temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
|
1131 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
|
1132 |
|
|
return err;
|
1133 |
|
|
}
|
1134 |
|
|
|
1135 |
|
|
/* monitoring */
|
1136 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_vol, chip))) < 0)
|
1137 |
|
|
return err;
|
1138 |
|
|
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_sw, chip))) < 0)
|
1139 |
|
|
return err;
|
1140 |
|
|
|
1141 |
|
|
/* init all mixer data and program the master volumes/switches */
|
1142 |
|
|
mixart_reset_audio_levels(chip);
|
1143 |
|
|
}
|
1144 |
|
|
return 0;
|
1145 |
|
|
}
|