Merge tag 'driver-core-4.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / sound / pci / ice1712 / wtm.c
CommitLineData
f6cdab5f
CG
1/*
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
f14d8e97 3 *
f6cdab5f
CG
4 * Lowlevel functions for Ego Sys Waveterminal 192M
5 *
6 * Copyright (c) 2006 Guedez Clement <klem.dev@gmail.com>
7 * Some functions are taken from the Prodigy192 driver
8 * source
f14d8e97 9 *
f6cdab5f
CG
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f14d8e97
AB
23 *
24 */
f6cdab5f
CG
25
26
27
f6cdab5f
CG
28#include <linux/delay.h>
29#include <linux/interrupt.h>
30#include <linux/init.h>
f6cdab5f 31#include <sound/core.h>
16ddbe73 32#include <sound/tlv.h>
1aa9a4ea 33#include <linux/slab.h>
f6cdab5f
CG
34
35#include "ice1712.h"
36#include "envy24ht.h"
37#include "wtm.h"
38#include "stac946x.h"
39
1aa9a4ea
CG
40struct wtm_spec {
41 /* rate change needs atomic mute/unmute of all dacs*/
42 struct mutex mute_mutex;
43};
44
f6cdab5f
CG
45
46/*
f14d8e97 47 * 2*ADC 6*DAC no1 ringbuffer r/w on i2c bus
f6cdab5f 48 */
f14d8e97 49static inline void stac9460_put(struct snd_ice1712 *ice, int reg,
f6cdab5f
CG
50 unsigned char val)
51{
52 snd_vt1724_write_i2c(ice, STAC9460_I2C_ADDR, reg, val);
53}
54
55static inline unsigned char stac9460_get(struct snd_ice1712 *ice, int reg)
56{
57 return snd_vt1724_read_i2c(ice, STAC9460_I2C_ADDR, reg);
58}
59
60/*
61 * 2*ADC 2*DAC no2 ringbuffer r/w on i2c bus
62 */
63static inline void stac9460_2_put(struct snd_ice1712 *ice, int reg,
64 unsigned char val)
65{
66 snd_vt1724_write_i2c(ice, STAC9460_2_I2C_ADDR, reg, val);
67}
68
69static inline unsigned char stac9460_2_get(struct snd_ice1712 *ice, int reg)
70{
71 return snd_vt1724_read_i2c(ice, STAC9460_2_I2C_ADDR, reg);
72}
73
74
75/*
76 * DAC mute control
77 */
1aa9a4ea
CG
78static void stac9460_dac_mute_all(struct snd_ice1712 *ice, unsigned char mute,
79 unsigned short int *change_mask)
80{
81 unsigned char new, old;
82 int id, idx, change;
83
84 /*stac9460 1*/
85 for (id = 0; id < 7; id++) {
86 if (*change_mask & (0x01 << id)) {
87 if (id == 0)
88 idx = STAC946X_MASTER_VOLUME;
89 else
90 idx = STAC946X_LF_VOLUME - 1 + id;
91 old = stac9460_get(ice, idx);
92 new = (~mute << 7 & 0x80) | (old & ~0x80);
93 change = (new != old);
94 if (change) {
95 stac9460_put(ice, idx, new);
96 *change_mask = *change_mask | (0x01 << id);
97 } else {
98 *change_mask = *change_mask & ~(0x01 << id);
99 }
100 }
101 }
102
103 /*stac9460 2*/
104 for (id = 0; id < 3; id++) {
105 if (*change_mask & (0x01 << (id + 7))) {
106 if (id == 0)
107 idx = STAC946X_MASTER_VOLUME;
108 else
109 idx = STAC946X_LF_VOLUME - 1 + id;
110 old = stac9460_2_get(ice, idx);
111 new = (~mute << 7 & 0x80) | (old & ~0x80);
112 change = (new != old);
113 if (change) {
114 stac9460_2_put(ice, idx, new);
115 *change_mask = *change_mask | (0x01 << id);
116 } else {
117 *change_mask = *change_mask & ~(0x01 << id);
118 }
119 }
120 }
121}
122
123
124
a5ce8890 125#define stac9460_dac_mute_info snd_ctl_boolean_mono_info
f6cdab5f
CG
126
127static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol,
f14d8e97 128 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
129{
130 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1aa9a4ea 131 struct wtm_spec *spec = ice->spec;
f6cdab5f
CG
132 unsigned char val;
133 int idx, id;
134
1aa9a4ea
CG
135 mutex_lock(&spec->mute_mutex);
136
f6cdab5f
CG
137 if (kcontrol->private_value) {
138 idx = STAC946X_MASTER_VOLUME;
139 id = 0;
140 } else {
141 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
142 idx = id + STAC946X_LF_VOLUME;
143 }
144 if (id < 6)
145 val = stac9460_get(ice, idx);
f14d8e97
AB
146 else
147 val = stac9460_2_get(ice, idx - 6);
f6cdab5f 148 ucontrol->value.integer.value[0] = (~val >> 7) & 0x1;
1aa9a4ea
CG
149
150 mutex_unlock(&spec->mute_mutex);
f6cdab5f
CG
151 return 0;
152}
153
154static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol,
f14d8e97 155 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
156{
157 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
158 unsigned char new, old;
159 int id, idx;
160 int change;
161
162 if (kcontrol->private_value) {
163 idx = STAC946X_MASTER_VOLUME;
164 old = stac9460_get(ice, idx);
f14d8e97
AB
165 new = (~ucontrol->value.integer.value[0] << 7 & 0x80) |
166 (old & ~0x80);
f6cdab5f
CG
167 change = (new != old);
168 if (change) {
169 stac9460_put(ice, idx, new);
170 stac9460_2_put(ice, idx, new);
171 }
172 } else {
173 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
174 idx = id + STAC946X_LF_VOLUME;
175 if (id < 6)
176 old = stac9460_get(ice, idx);
f14d8e97 177 else
f6cdab5f 178 old = stac9460_2_get(ice, idx - 6);
f14d8e97 179 new = (~ucontrol->value.integer.value[0] << 7 & 0x80) |
f6cdab5f
CG
180 (old & ~0x80);
181 change = (new != old);
182 if (change) {
183 if (id < 6)
f14d8e97 184 stac9460_put(ice, idx, new);
f6cdab5f 185 else
f14d8e97 186 stac9460_2_put(ice, idx - 6, new);
f6cdab5f
CG
187 }
188 }
189 return change;
190}
191
192/*
193 * DAC volume attenuation mixer control
194 */
195static int stac9460_dac_vol_info(struct snd_kcontrol *kcontrol,
f14d8e97 196 struct snd_ctl_elem_info *uinfo)
f6cdab5f
CG
197{
198 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
199 uinfo->count = 1;
200 uinfo->value.integer.min = 0; /* mute */
201 uinfo->value.integer.max = 0x7f; /* 0dB */
202 return 0;
203}
204
205static int stac9460_dac_vol_get(struct snd_kcontrol *kcontrol,
f14d8e97 206 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
207{
208 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
209 int idx, id;
210 unsigned char vol;
211
212 if (kcontrol->private_value) {
213 idx = STAC946X_MASTER_VOLUME;
214 id = 0;
215 } else {
216 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
217 idx = id + STAC946X_LF_VOLUME;
218 }
219 if (id < 6)
220 vol = stac9460_get(ice, idx) & 0x7f;
f14d8e97 221 else
f6cdab5f
CG
222 vol = stac9460_2_get(ice, idx - 6) & 0x7f;
223 ucontrol->value.integer.value[0] = 0x7f - vol;
224 return 0;
225}
226
227static int stac9460_dac_vol_put(struct snd_kcontrol *kcontrol,
f14d8e97 228 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
229{
230 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
231 int idx, id;
232 unsigned char tmp, ovol, nvol;
233 int change;
234
235 if (kcontrol->private_value) {
236 idx = STAC946X_MASTER_VOLUME;
9cd17cd2 237 nvol = ucontrol->value.integer.value[0] & 0x7f;
f6cdab5f
CG
238 tmp = stac9460_get(ice, idx);
239 ovol = 0x7f - (tmp & 0x7f);
240 change = (ovol != nvol);
241 if (change) {
f14d8e97
AB
242 stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
243 stac9460_2_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
f6cdab5f
CG
244 }
245 } else {
246 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
247 idx = id + STAC946X_LF_VOLUME;
9cd17cd2 248 nvol = ucontrol->value.integer.value[0] & 0x7f;
f6cdab5f
CG
249 if (id < 6)
250 tmp = stac9460_get(ice, idx);
f14d8e97 251 else
f6cdab5f
CG
252 tmp = stac9460_2_get(ice, idx - 6);
253 ovol = 0x7f - (tmp & 0x7f);
254 change = (ovol != nvol);
255 if (change) {
256 if (id < 6)
257 stac9460_put(ice, idx, (0x7f - nvol) |
f14d8e97
AB
258 (tmp & 0x80));
259 else
f6cdab5f 260 stac9460_2_put(ice, idx-6, (0x7f - nvol) |
f14d8e97 261 (tmp & 0x80));
f6cdab5f
CG
262 }
263 }
264 return change;
265}
266
267/*
268 * ADC mute control
269 */
a5ce8890 270#define stac9460_adc_mute_info snd_ctl_boolean_stereo_info
f6cdab5f
CG
271
272static int stac9460_adc_mute_get(struct snd_kcontrol *kcontrol,
f14d8e97 273 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
274{
275 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
276 unsigned char val;
277 int i, id;
f14d8e97 278
f6cdab5f
CG
279 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
280 if (id == 0) {
281 for (i = 0; i < 2; ++i) {
282 val = stac9460_get(ice, STAC946X_MIC_L_VOLUME + i);
283 ucontrol->value.integer.value[i] = ~val>>7 & 0x1;
284 }
285 } else {
286 for (i = 0; i < 2; ++i) {
287 val = stac9460_2_get(ice, STAC946X_MIC_L_VOLUME + i);
288 ucontrol->value.integer.value[i] = ~val>>7 & 0x1;
289 }
290 }
291 return 0;
292}
293
294static int stac9460_adc_mute_put(struct snd_kcontrol *kcontrol,
f14d8e97 295 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
296{
297 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
298 unsigned char new, old;
299 int i, reg, id;
300 int change;
f14d8e97 301
f6cdab5f
CG
302 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
303 if (id == 0) {
304 for (i = 0; i < 2; ++i) {
305 reg = STAC946X_MIC_L_VOLUME + i;
306 old = stac9460_get(ice, reg);
307 new = (~ucontrol->value.integer.value[i]<<7&0x80) |
f14d8e97 308 (old&~0x80);
f6cdab5f
CG
309 change = (new != old);
310 if (change)
311 stac9460_put(ice, reg, new);
312 }
313 } else {
314 for (i = 0; i < 2; ++i) {
315 reg = STAC946X_MIC_L_VOLUME + i;
316 old = stac9460_2_get(ice, reg);
317 new = (~ucontrol->value.integer.value[i]<<7&0x80) |
f14d8e97 318 (old&~0x80);
f6cdab5f
CG
319 change = (new != old);
320 if (change)
321 stac9460_2_put(ice, reg, new);
322 }
323 }
324 return change;
325}
326
327/*
328 *ADC gain mixer control
329 */
330static int stac9460_adc_vol_info(struct snd_kcontrol *kcontrol,
f14d8e97 331 struct snd_ctl_elem_info *uinfo)
f6cdab5f
CG
332{
333 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
334 uinfo->count = 2;
335 uinfo->value.integer.min = 0; /* 0dB */
336 uinfo->value.integer.max = 0x0f; /* 22.5dB */
337 return 0;
338}
339
340static int stac9460_adc_vol_get(struct snd_kcontrol *kcontrol,
f14d8e97 341 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
342{
343 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
344 int i, reg, id;
345 unsigned char vol;
f14d8e97 346
f6cdab5f
CG
347 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
348 if (id == 0) {
349 for (i = 0; i < 2; ++i) {
350 reg = STAC946X_MIC_L_VOLUME + i;
351 vol = stac9460_get(ice, reg) & 0x0f;
352 ucontrol->value.integer.value[i] = 0x0f - vol;
353 }
354 } else {
355 for (i = 0; i < 2; ++i) {
356 reg = STAC946X_MIC_L_VOLUME + i;
357 vol = stac9460_2_get(ice, reg) & 0x0f;
358 ucontrol->value.integer.value[i] = 0x0f - vol;
359 }
360 }
361 return 0;
362}
363
364static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol,
f14d8e97 365 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
366{
367 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
368 int i, reg, id;
369 unsigned char ovol, nvol;
370 int change;
f14d8e97 371
f6cdab5f
CG
372 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
373 if (id == 0) {
374 for (i = 0; i < 2; ++i) {
375 reg = STAC946X_MIC_L_VOLUME + i;
9cd17cd2 376 nvol = ucontrol->value.integer.value[i] & 0x0f;
f6cdab5f
CG
377 ovol = 0x0f - stac9460_get(ice, reg);
378 change = ((ovol & 0x0f) != nvol);
379 if (change)
380 stac9460_put(ice, reg, (0x0f - nvol) |
f14d8e97 381 (ovol & ~0x0f));
f6cdab5f
CG
382 }
383 } else {
384 for (i = 0; i < 2; ++i) {
385 reg = STAC946X_MIC_L_VOLUME + i;
9cd17cd2 386 nvol = ucontrol->value.integer.value[i] & 0x0f;
f6cdab5f
CG
387 ovol = 0x0f - stac9460_2_get(ice, reg);
388 change = ((ovol & 0x0f) != nvol);
389 if (change)
390 stac9460_2_put(ice, reg, (0x0f - nvol) |
f14d8e97 391 (ovol & ~0x0f));
f6cdab5f
CG
392 }
393 }
394 return change;
395}
396
397/*
398 * MIC / LINE switch fonction
399 */
ae8a9a11
CG
400static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
401 struct snd_ctl_elem_info *uinfo)
402{
403 static const char * const texts[2] = { "Line In", "Mic" };
404
405 return snd_ctl_enum_info(uinfo, 1, 2, texts);
406}
f6cdab5f 407
f6cdab5f
CG
408
409static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
f14d8e97 410 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
411{
412 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
413 unsigned char val;
414 int id;
f14d8e97 415
f6cdab5f
CG
416 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
417 if (id == 0)
f14d8e97 418 val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
f6cdab5f 419 else
f14d8e97 420 val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
ae8a9a11 421 ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1;
f6cdab5f
CG
422 return 0;
423}
424
425static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
f14d8e97 426 struct snd_ctl_elem_value *ucontrol)
f6cdab5f
CG
427{
428 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
429 unsigned char new, old;
430 int change, id;
431
432 id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
433 if (id == 0)
f14d8e97 434 old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
f6cdab5f 435 else
f14d8e97 436 old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
ae8a9a11 437 new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80);
f6cdab5f
CG
438 change = (new != old);
439 if (change) {
440 if (id == 0)
f14d8e97 441 stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
f6cdab5f 442 else
f14d8e97 443 stac9460_2_put(ice, STAC946X_GENERAL_PURPOSE, new);
f6cdab5f
CG
444 }
445 return change;
446}
447
16ddbe73 448
1aa9a4ea
CG
449/*
450 * Handler for setting correct codec rate - called when rate change is detected
451 */
452static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
453{
454 unsigned char old, new;
455 unsigned short int changed;
456 struct wtm_spec *spec = ice->spec;
457
458 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
459 return;
460 else if (rate <= 48000)
461 new = 0x08; /* 256x, base rate mode */
462 else if (rate <= 96000)
463 new = 0x11; /* 256x, mid rate mode */
464 else
465 new = 0x12; /* 128x, high rate mode */
466
467 old = stac9460_get(ice, STAC946X_MASTER_CLOCKING);
468 if (old == new)
469 return;
470 /* change detected, setting master clock, muting first */
471 /* due to possible conflicts with mute controls - mutexing */
472 mutex_lock(&spec->mute_mutex);
473 /* we have to remember current mute status for each DAC */
474 changed = 0xFFFF;
475 stac9460_dac_mute_all(ice, 0, &changed);
476 /*printk(KERN_DEBUG "Rate change: %d, new MC: 0x%02x\n", rate, new);*/
477 stac9460_put(ice, STAC946X_MASTER_CLOCKING, new);
478 stac9460_2_put(ice, STAC946X_MASTER_CLOCKING, new);
479 udelay(10);
480 /* unmuting - only originally unmuted dacs -
481 * i.e. those changed when muting */
482 stac9460_dac_mute_all(ice, 1, &changed);
483 mutex_unlock(&spec->mute_mutex);
484}
485
486
16ddbe73
CG
487/*Limits value in dB for fader*/
488static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
489static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
490
f6cdab5f
CG
491/*
492 * Control tabs
493 */
e23e7a14 494static struct snd_kcontrol_new stac9640_controls[] = {
f6cdab5f
CG
495 {
496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16ddbe73
CG
497 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
498 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
f6cdab5f
CG
499 .name = "Master Playback Switch",
500 .info = stac9460_dac_mute_info,
501 .get = stac9460_dac_mute_get,
502 .put = stac9460_dac_mute_put,
16ddbe73
CG
503 .private_value = 1,
504 .tlv = { .p = db_scale_dac }
f6cdab5f
CG
505 },
506 {
507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
508 .name = "Master Playback Volume",
509 .info = stac9460_dac_vol_info,
510 .get = stac9460_dac_vol_get,
511 .put = stac9460_dac_vol_put,
512 .private_value = 1,
513 },
514 {
515 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
ae8a9a11 516 .name = "MIC/Line Input Enum",
f6cdab5f
CG
517 .count = 2,
518 .info = stac9460_mic_sw_info,
519 .get = stac9460_mic_sw_get,
520 .put = stac9460_mic_sw_put,
521
522 },
523 {
524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
525 .name = "DAC Switch",
526 .count = 8,
527 .info = stac9460_dac_mute_info,
528 .get = stac9460_dac_mute_get,
529 .put = stac9460_dac_mute_put,
530 },
531 {
532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16ddbe73
CG
533 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
534 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
535
f6cdab5f
CG
536 .name = "DAC Volume",
537 .count = 8,
538 .info = stac9460_dac_vol_info,
539 .get = stac9460_dac_vol_get,
540 .put = stac9460_dac_vol_put,
16ddbe73 541 .tlv = { .p = db_scale_dac }
f6cdab5f
CG
542 },
543 {
544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
545 .name = "ADC Switch",
546 .count = 2,
547 .info = stac9460_adc_mute_info,
548 .get = stac9460_adc_mute_get,
549 .put = stac9460_adc_mute_put,
550 },
551 {
552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16ddbe73
CG
553 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
554 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
555
f6cdab5f
CG
556 .name = "ADC Volume",
557 .count = 2,
558 .info = stac9460_adc_vol_info,
559 .get = stac9460_adc_vol_get,
560 .put = stac9460_adc_vol_put,
16ddbe73 561 .tlv = { .p = db_scale_adc }
f14d8e97 562 }
f6cdab5f
CG
563};
564
565
566
567/*INIT*/
e23e7a14 568static int wtm_add_controls(struct snd_ice1712 *ice)
f6cdab5f
CG
569{
570 unsigned int i;
571 int err;
572
573 for (i = 0; i < ARRAY_SIZE(stac9640_controls); i++) {
574 err = snd_ctl_add(ice->card,
575 snd_ctl_new1(&stac9640_controls[i], ice));
576 if (err < 0)
577 return err;
578 }
579 return 0;
580}
581
e23e7a14 582static int wtm_init(struct snd_ice1712 *ice)
f6cdab5f 583{
b56df151 584 static unsigned short stac_inits_wtm[] = {
f6cdab5f 585 STAC946X_RESET, 0,
1aa9a4ea 586 STAC946X_MASTER_CLOCKING, 0x11,
f6cdab5f
CG
587 (unsigned short)-1
588 };
589 unsigned short *p;
1aa9a4ea 590 struct wtm_spec *spec;
f14d8e97 591
f6cdab5f
CG
592 /*WTM 192M*/
593 ice->num_total_dacs = 8;
594 ice->num_total_adcs = 4;
595 ice->force_rdma1 = 1;
596
1aa9a4ea
CG
597 /*init mutex for dac mute conflict*/
598 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
599 if (!spec)
600 return -ENOMEM;
601 ice->spec = spec;
602 mutex_init(&spec->mute_mutex);
603
604
f6cdab5f 605 /*initialize codec*/
b56df151 606 p = stac_inits_wtm;
f6cdab5f
CG
607 for (; *p != (unsigned short)-1; p += 2) {
608 stac9460_put(ice, p[0], p[1]);
609 stac9460_2_put(ice, p[0], p[1]);
610 }
1aa9a4ea 611 ice->gpio.set_pro_rate = stac9460_set_rate_val;
f6cdab5f
CG
612 return 0;
613}
614
615
e23e7a14 616static unsigned char wtm_eeprom[] = {
f8a8b3a8
CG
617 [ICE_EEP2_SYSCONF] = 0x67, /*SYSCONF: clock 192KHz, mpu401,
618 4ADC, 8DAC */
7127744a
CG
619 [ICE_EEP2_ACLINK] = 0x80, /* ACLINK : I2S */
620 [ICE_EEP2_I2S] = 0xf8, /* I2S: vol; 96k, 24bit, 192k */
621 [ICE_EEP2_SPDIF] = 0xc1, /*SPDIF: out-en, spidf ext out*/
622 [ICE_EEP2_GPIO_DIR] = 0x9f,
623 [ICE_EEP2_GPIO_DIR1] = 0xff,
624 [ICE_EEP2_GPIO_DIR2] = 0x7f,
625 [ICE_EEP2_GPIO_MASK] = 0x9f,
626 [ICE_EEP2_GPIO_MASK1] = 0xff,
627 [ICE_EEP2_GPIO_MASK2] = 0x7f,
628 [ICE_EEP2_GPIO_STATE] = 0x16,
629 [ICE_EEP2_GPIO_STATE1] = 0x80,
630 [ICE_EEP2_GPIO_STATE2] = 0x00,
f6cdab5f
CG
631};
632
633
634/*entry point*/
e23e7a14 635struct snd_ice1712_card_info snd_vt1724_wtm_cards[] = {
f6cdab5f
CG
636 {
637 .subvendor = VT1724_SUBDEVICE_WTM,
638 .name = "ESI Waveterminal 192M",
639 .model = "WT192M",
640 .chip_init = wtm_init,
641 .build_controls = wtm_add_controls,
642 .eeprom_size = sizeof(wtm_eeprom),
643 .eeprom_data = wtm_eeprom,
644 },
645 {} /*terminator*/
646};
This page took 0.667715 seconds and 5 git commands to generate.