2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>,
3 * Takashi Iwai <tiwai@suse.de>
5 * Routines for control of EMU10K1 chips / mixer routines
6 * Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com>
8 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
9 * Added EMU 1010 support.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include <sound/driver.h>
34 #include <linux/time.h>
35 #include <linux/init.h>
36 #include <sound/core.h>
37 #include <sound/emu10k1.h>
38 #include <linux/delay.h>
39 #include <sound/tlv.h>
43 #define AC97_ID_STAC9758 0x83847658
45 static const DECLARE_TLV_DB_SCALE(snd_audigy_db_scale2
, -10350, 50, 1); /* WM8775 gain scale */
47 static int snd_emu10k1_spdif_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
49 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
54 static int snd_emu10k1_spdif_get(struct snd_kcontrol
*kcontrol
,
55 struct snd_ctl_elem_value
*ucontrol
)
57 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
58 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
61 spin_lock_irqsave(&emu
->reg_lock
, flags
);
62 ucontrol
->value
.iec958
.status
[0] = (emu
->spdif_bits
[idx
] >> 0) & 0xff;
63 ucontrol
->value
.iec958
.status
[1] = (emu
->spdif_bits
[idx
] >> 8) & 0xff;
64 ucontrol
->value
.iec958
.status
[2] = (emu
->spdif_bits
[idx
] >> 16) & 0xff;
65 ucontrol
->value
.iec958
.status
[3] = (emu
->spdif_bits
[idx
] >> 24) & 0xff;
66 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
70 static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol
*kcontrol
,
71 struct snd_ctl_elem_value
*ucontrol
)
73 ucontrol
->value
.iec958
.status
[0] = 0xff;
74 ucontrol
->value
.iec958
.status
[1] = 0xff;
75 ucontrol
->value
.iec958
.status
[2] = 0xff;
76 ucontrol
->value
.iec958
.status
[3] = 0xff;
80 static char *emu1010_src_texts
[] = {
136 static unsigned int emu1010_src_regs
[] = {
137 EMU_SRC_SILENCE
,/* 0 */
138 EMU_SRC_DOCK_MIC_A1
, /* 1 */
139 EMU_SRC_DOCK_MIC_B1
, /* 2 */
140 EMU_SRC_DOCK_ADC1_LEFT1
, /* 3 */
141 EMU_SRC_DOCK_ADC1_RIGHT1
, /* 4 */
142 EMU_SRC_DOCK_ADC2_LEFT1
, /* 5 */
143 EMU_SRC_DOCK_ADC2_RIGHT1
, /* 6 */
144 EMU_SRC_DOCK_ADC3_LEFT1
, /* 7 */
145 EMU_SRC_DOCK_ADC3_RIGHT1
, /* 8 */
146 EMU_SRC_HAMOA_ADC_LEFT1
, /* 9 */
147 EMU_SRC_HAMOA_ADC_RIGHT1
, /* 10 */
148 EMU_SRC_HANA_SPDIF_LEFT1
, /* 11 */
149 EMU_SRC_HANA_SPDIF_RIGHT1
, /* 12 */
150 EMU_SRC_HANA_ADAT
, /* 13 */
151 EMU_SRC_HANA_ADAT
+1, /* 14 */
152 EMU_SRC_HANA_ADAT
+2, /* 15 */
153 EMU_SRC_HANA_ADAT
+3, /* 16 */
154 EMU_SRC_HANA_ADAT
+4, /* 17 */
155 EMU_SRC_HANA_ADAT
+5, /* 18 */
156 EMU_SRC_HANA_ADAT
+6, /* 19 */
157 EMU_SRC_HANA_ADAT
+7, /* 20 */
158 EMU_SRC_ALICE_EMU32A
, /* 21 */
159 EMU_SRC_ALICE_EMU32A
+1, /* 22 */
160 EMU_SRC_ALICE_EMU32A
+2, /* 23 */
161 EMU_SRC_ALICE_EMU32A
+3, /* 24 */
162 EMU_SRC_ALICE_EMU32A
+4, /* 25 */
163 EMU_SRC_ALICE_EMU32A
+5, /* 26 */
164 EMU_SRC_ALICE_EMU32A
+6, /* 27 */
165 EMU_SRC_ALICE_EMU32A
+7, /* 28 */
166 EMU_SRC_ALICE_EMU32A
+8, /* 29 */
167 EMU_SRC_ALICE_EMU32A
+9, /* 30 */
168 EMU_SRC_ALICE_EMU32A
+0xa, /* 31 */
169 EMU_SRC_ALICE_EMU32A
+0xb, /* 32 */
170 EMU_SRC_ALICE_EMU32A
+0xc, /* 33 */
171 EMU_SRC_ALICE_EMU32A
+0xd, /* 34 */
172 EMU_SRC_ALICE_EMU32A
+0xe, /* 35 */
173 EMU_SRC_ALICE_EMU32A
+0xf, /* 36 */
174 EMU_SRC_ALICE_EMU32B
, /* 37 */
175 EMU_SRC_ALICE_EMU32B
+1, /* 38 */
176 EMU_SRC_ALICE_EMU32B
+2, /* 39 */
177 EMU_SRC_ALICE_EMU32B
+3, /* 40 */
178 EMU_SRC_ALICE_EMU32B
+4, /* 41 */
179 EMU_SRC_ALICE_EMU32B
+5, /* 42 */
180 EMU_SRC_ALICE_EMU32B
+6, /* 43 */
181 EMU_SRC_ALICE_EMU32B
+7, /* 44 */
182 EMU_SRC_ALICE_EMU32B
+8, /* 45 */
183 EMU_SRC_ALICE_EMU32B
+9, /* 46 */
184 EMU_SRC_ALICE_EMU32B
+0xa, /* 47 */
185 EMU_SRC_ALICE_EMU32B
+0xb, /* 48 */
186 EMU_SRC_ALICE_EMU32B
+0xc, /* 49 */
187 EMU_SRC_ALICE_EMU32B
+0xd, /* 50 */
188 EMU_SRC_ALICE_EMU32B
+0xe, /* 51 */
189 EMU_SRC_ALICE_EMU32B
+0xf, /* 52 */
192 static unsigned int emu1010_output_dst
[] = {
193 EMU_DST_DOCK_DAC1_LEFT1
, /* 0 */
194 EMU_DST_DOCK_DAC1_RIGHT1
, /* 1 */
195 EMU_DST_DOCK_DAC2_LEFT1
, /* 2 */
196 EMU_DST_DOCK_DAC2_RIGHT1
, /* 3 */
197 EMU_DST_DOCK_DAC3_LEFT1
, /* 4 */
198 EMU_DST_DOCK_DAC3_RIGHT1
, /* 5 */
199 EMU_DST_DOCK_DAC4_LEFT1
, /* 6 */
200 EMU_DST_DOCK_DAC4_RIGHT1
, /* 7 */
201 EMU_DST_DOCK_PHONES_LEFT1
, /* 8 */
202 EMU_DST_DOCK_PHONES_RIGHT1
, /* 9 */
203 EMU_DST_DOCK_SPDIF_LEFT1
, /* 10 */
204 EMU_DST_DOCK_SPDIF_RIGHT1
, /* 11 */
205 EMU_DST_HANA_SPDIF_LEFT1
, /* 12 */
206 EMU_DST_HANA_SPDIF_RIGHT1
, /* 13 */
207 EMU_DST_HAMOA_DAC_LEFT1
, /* 14 */
208 EMU_DST_HAMOA_DAC_RIGHT1
, /* 15 */
209 EMU_DST_HANA_ADAT
, /* 16 */
210 EMU_DST_HANA_ADAT
+1, /* 17 */
211 EMU_DST_HANA_ADAT
+2, /* 18 */
212 EMU_DST_HANA_ADAT
+3, /* 19 */
213 EMU_DST_HANA_ADAT
+4, /* 20 */
214 EMU_DST_HANA_ADAT
+5, /* 21 */
215 EMU_DST_HANA_ADAT
+6, /* 22 */
216 EMU_DST_HANA_ADAT
+7, /* 23 */
219 static unsigned int emu1010_input_dst
[] = {
220 EMU_DST_ALICE2_EMU32_0
,
221 EMU_DST_ALICE2_EMU32_1
,
222 EMU_DST_ALICE2_EMU32_2
,
223 EMU_DST_ALICE2_EMU32_3
,
224 EMU_DST_ALICE2_EMU32_4
,
225 EMU_DST_ALICE2_EMU32_5
,
226 EMU_DST_ALICE2_EMU32_6
,
227 EMU_DST_ALICE2_EMU32_7
,
228 EMU_DST_ALICE2_EMU32_8
,
229 EMU_DST_ALICE2_EMU32_9
,
230 EMU_DST_ALICE2_EMU32_A
,
231 EMU_DST_ALICE2_EMU32_B
,
232 EMU_DST_ALICE2_EMU32_C
,
233 EMU_DST_ALICE2_EMU32_D
,
234 EMU_DST_ALICE2_EMU32_E
,
235 EMU_DST_ALICE2_EMU32_F
,
236 EMU_DST_ALICE_I2S0_LEFT
,
237 EMU_DST_ALICE_I2S0_RIGHT
,
238 EMU_DST_ALICE_I2S1_LEFT
,
239 EMU_DST_ALICE_I2S1_RIGHT
,
240 EMU_DST_ALICE_I2S2_LEFT
,
241 EMU_DST_ALICE_I2S2_RIGHT
,
244 static int snd_emu1010_input_output_source_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
246 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
248 uinfo
->value
.enumerated
.items
= 53;
249 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
250 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
251 strcpy(uinfo
->value
.enumerated
.name
, emu1010_src_texts
[uinfo
->value
.enumerated
.item
]);
255 static int snd_emu1010_output_source_get(struct snd_kcontrol
*kcontrol
,
256 struct snd_ctl_elem_value
*ucontrol
)
258 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
261 channel
= (kcontrol
->private_value
) & 0xff;
262 ucontrol
->value
.enumerated
.item
[0] = emu
->emu1010
.output_source
[channel
];
266 static int snd_emu1010_output_source_put(struct snd_kcontrol
*kcontrol
,
267 struct snd_ctl_elem_value
*ucontrol
)
269 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
274 channel
= (kcontrol
->private_value
) & 0xff;
275 if (emu
->emu1010
.output_source
[channel
] != ucontrol
->value
.enumerated
.item
[0]) {
276 val
= emu
->emu1010
.output_source
[channel
] = ucontrol
->value
.enumerated
.item
[0];
278 snd_emu1010_fpga_link_dst_src_write(emu
,
279 emu1010_output_dst
[channel
], emu1010_src_regs
[val
]);
284 static int snd_emu1010_input_source_get(struct snd_kcontrol
*kcontrol
,
285 struct snd_ctl_elem_value
*ucontrol
)
287 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
290 channel
= (kcontrol
->private_value
) & 0xff;
291 ucontrol
->value
.enumerated
.item
[0] = emu
->emu1010
.input_source
[channel
];
295 static int snd_emu1010_input_source_put(struct snd_kcontrol
*kcontrol
,
296 struct snd_ctl_elem_value
*ucontrol
)
298 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
303 channel
= (kcontrol
->private_value
) & 0xff;
304 if (emu
->emu1010
.input_source
[channel
] != ucontrol
->value
.enumerated
.item
[0]) {
305 val
= emu
->emu1010
.input_source
[channel
] = ucontrol
->value
.enumerated
.item
[0];
307 snd_emu1010_fpga_link_dst_src_write(emu
,
308 emu1010_input_dst
[channel
], emu1010_src_regs
[val
]);
313 #define EMU1010_SOURCE_OUTPUT(xname,chid) \
315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
316 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
317 .info = snd_emu1010_input_output_source_info, \
318 .get = snd_emu1010_output_source_get, \
319 .put = snd_emu1010_output_source_put, \
320 .private_value = chid \
323 static struct snd_kcontrol_new snd_emu1010_output_enum_ctls
[] __devinitdata
= {
324 EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0),
325 EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1),
326 EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Enum", 2),
327 EMU1010_SOURCE_OUTPUT("Dock DAC2 Right Playback Enum", 3),
328 EMU1010_SOURCE_OUTPUT("Dock DAC3 Left Playback Enum", 4),
329 EMU1010_SOURCE_OUTPUT("Dock DAC3 Right Playback Enum", 5),
330 EMU1010_SOURCE_OUTPUT("Dock DAC4 Left Playback Enum", 6),
331 EMU1010_SOURCE_OUTPUT("Dock DAC4 Right Playback Enum", 7),
332 EMU1010_SOURCE_OUTPUT("Dock Phones Left Playback Enum", 8),
333 EMU1010_SOURCE_OUTPUT("Dock Phones Right Playback Enum", 9),
334 EMU1010_SOURCE_OUTPUT("Dock SPDIF Left Playback Enum", 0xa),
335 EMU1010_SOURCE_OUTPUT("Dock SPDIF Right Playback Enum", 0xb),
336 EMU1010_SOURCE_OUTPUT("1010 SPDIF Left Playback Enum", 0xc),
337 EMU1010_SOURCE_OUTPUT("1010 SPDIF Right Playback Enum", 0xd),
338 EMU1010_SOURCE_OUTPUT("0202 DAC Left Playback Enum", 0xe),
339 EMU1010_SOURCE_OUTPUT("0202 DAC Right Playback Enum", 0xf),
340 EMU1010_SOURCE_OUTPUT("1010 ADAT 0 Playback Enum", 0x10),
341 EMU1010_SOURCE_OUTPUT("1010 ADAT 1 Playback Enum", 0x11),
342 EMU1010_SOURCE_OUTPUT("1010 ADAT 2 Playback Enum", 0x12),
343 EMU1010_SOURCE_OUTPUT("1010 ADAT 3 Playback Enum", 0x13),
344 EMU1010_SOURCE_OUTPUT("1010 ADAT 4 Playback Enum", 0x14),
345 EMU1010_SOURCE_OUTPUT("1010 ADAT 5 Playback Enum", 0x15),
346 EMU1010_SOURCE_OUTPUT("1010 ADAT 6 Playback Enum", 0x16),
347 EMU1010_SOURCE_OUTPUT("1010 ADAT 7 Playback Enum", 0x17),
350 #define EMU1010_SOURCE_INPUT(xname,chid) \
352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
353 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
354 .info = snd_emu1010_input_output_source_info, \
355 .get = snd_emu1010_input_source_get, \
356 .put = snd_emu1010_input_source_put, \
357 .private_value = chid \
360 static struct snd_kcontrol_new snd_emu1010_input_enum_ctls
[] __devinitdata
= {
361 EMU1010_SOURCE_INPUT("DSP 0 Capture Enum", 0),
362 EMU1010_SOURCE_INPUT("DSP 1 Capture Enum", 1),
363 EMU1010_SOURCE_INPUT("DSP 2 Capture Enum", 2),
364 EMU1010_SOURCE_INPUT("DSP 3 Capture Enum", 3),
365 EMU1010_SOURCE_INPUT("DSP 4 Capture Enum", 4),
366 EMU1010_SOURCE_INPUT("DSP 5 Capture Enum", 5),
367 EMU1010_SOURCE_INPUT("DSP 6 Capture Enum", 6),
368 EMU1010_SOURCE_INPUT("DSP 7 Capture Enum", 7),
369 EMU1010_SOURCE_INPUT("DSP 8 Capture Enum", 8),
370 EMU1010_SOURCE_INPUT("DSP 9 Capture Enum", 9),
371 EMU1010_SOURCE_INPUT("DSP A Capture Enum", 0xa),
372 EMU1010_SOURCE_INPUT("DSP B Capture Enum", 0xb),
373 EMU1010_SOURCE_INPUT("DSP C Capture Enum", 0xc),
374 EMU1010_SOURCE_INPUT("DSP D Capture Enum", 0xd),
375 EMU1010_SOURCE_INPUT("DSP E Capture Enum", 0xe),
376 EMU1010_SOURCE_INPUT("DSP F Capture Enum", 0xf),
377 EMU1010_SOURCE_INPUT("DSP 10 Capture Enum", 0x10),
378 EMU1010_SOURCE_INPUT("DSP 11 Capture Enum", 0x11),
379 EMU1010_SOURCE_INPUT("DSP 12 Capture Enum", 0x12),
380 EMU1010_SOURCE_INPUT("DSP 13 Capture Enum", 0x13),
381 EMU1010_SOURCE_INPUT("DSP 14 Capture Enum", 0x14),
382 EMU1010_SOURCE_INPUT("DSP 15 Capture Enum", 0x15),
388 static int snd_emu1010_adc_pads_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
390 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
392 uinfo
->value
.integer
.min
= 0;
393 uinfo
->value
.integer
.max
= 1;
397 static int snd_emu1010_adc_pads_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
399 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
400 unsigned int mask
= kcontrol
->private_value
& 0xff;
401 ucontrol
->value
.integer
.value
[0] = (emu
->emu1010
.adc_pads
& mask
) ? 1 : 0;
405 static int snd_emu1010_adc_pads_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
407 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
408 unsigned int mask
= kcontrol
->private_value
& 0xff;
409 unsigned int val
, cache
;
410 val
= ucontrol
->value
.integer
.value
[0];
411 cache
= emu
->emu1010
.adc_pads
;
413 cache
= cache
| mask
;
415 cache
= cache
& ~mask
;
416 if (cache
!= emu
->emu1010
.adc_pads
) {
417 snd_emu1010_fpga_write(emu
, EMU_HANA_ADC_PADS
, cache
);
418 emu
->emu1010
.adc_pads
= cache
;
426 #define EMU1010_ADC_PADS(xname,chid) \
428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
429 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
430 .info = snd_emu1010_adc_pads_info, \
431 .get = snd_emu1010_adc_pads_get, \
432 .put = snd_emu1010_adc_pads_put, \
433 .private_value = chid \
436 static struct snd_kcontrol_new snd_emu1010_adc_pads
[] __devinitdata
= {
437 EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1
),
438 EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2
),
439 EMU1010_ADC_PADS("ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3
),
440 EMU1010_ADC_PADS("ADC1 14dB PAD 0202 Capture Switch", EMU_HANA_0202_ADC_PAD1
),
443 static int snd_emu1010_dac_pads_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
445 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
447 uinfo
->value
.integer
.min
= 0;
448 uinfo
->value
.integer
.max
= 1;
452 static int snd_emu1010_dac_pads_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
454 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
455 unsigned int mask
= kcontrol
->private_value
& 0xff;
456 ucontrol
->value
.integer
.value
[0] = (emu
->emu1010
.dac_pads
& mask
) ? 1 : 0;
460 static int snd_emu1010_dac_pads_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
462 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
463 unsigned int mask
= kcontrol
->private_value
& 0xff;
464 unsigned int val
, cache
;
465 val
= ucontrol
->value
.integer
.value
[0];
466 cache
= emu
->emu1010
.dac_pads
;
468 cache
= cache
| mask
;
470 cache
= cache
& ~mask
;
471 if (cache
!= emu
->emu1010
.dac_pads
) {
472 snd_emu1010_fpga_write(emu
, EMU_HANA_DAC_PADS
, cache
);
473 emu
->emu1010
.dac_pads
= cache
;
481 #define EMU1010_DAC_PADS(xname,chid) \
483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
484 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
485 .info = snd_emu1010_dac_pads_info, \
486 .get = snd_emu1010_dac_pads_get, \
487 .put = snd_emu1010_dac_pads_put, \
488 .private_value = chid \
491 static struct snd_kcontrol_new snd_emu1010_dac_pads
[] __devinitdata
= {
492 EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1
),
493 EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2
),
494 EMU1010_DAC_PADS("DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3
),
495 EMU1010_DAC_PADS("DAC4 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD4
),
496 EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1
),
500 static int snd_emu1010_internal_clock_info(struct snd_kcontrol
*kcontrol
,
501 struct snd_ctl_elem_info
*uinfo
)
503 static char *texts
[2] = {
507 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
509 uinfo
->value
.enumerated
.items
= 2;
510 if (uinfo
->value
.enumerated
.item
> 1)
511 uinfo
->value
.enumerated
.item
= 1;
512 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
516 static int snd_emu1010_internal_clock_get(struct snd_kcontrol
*kcontrol
,
517 struct snd_ctl_elem_value
*ucontrol
)
519 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
521 ucontrol
->value
.enumerated
.item
[0] = emu
->emu1010
.internal_clock
;
525 static int snd_emu1010_internal_clock_put(struct snd_kcontrol
*kcontrol
,
526 struct snd_ctl_elem_value
*ucontrol
)
528 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
532 val
= ucontrol
->value
.enumerated
.item
[0] ;
533 change
= (emu
->emu1010
.internal_clock
!= val
);
535 emu
->emu1010
.internal_clock
= val
;
540 snd_emu1010_fpga_write(emu
, EMU_HANA_UNMUTE
, EMU_MUTE
);
541 /* Default fallback clock 48kHz */
542 snd_emu1010_fpga_write(emu
, EMU_HANA_DEFCLOCK
, EMU_HANA_DEFCLOCK_44_1K
);
543 /* Word Clock source, Internal 44.1kHz x1 */
544 snd_emu1010_fpga_write(emu
, EMU_HANA_WCLOCK
,
545 EMU_HANA_WCLOCK_INT_44_1K
| EMU_HANA_WCLOCK_1X
);
546 /* Set LEDs on Audio Dock */
547 snd_emu1010_fpga_write(emu
, EMU_HANA_DOCK_LEDS_2
,
548 EMU_HANA_DOCK_LEDS_2_44K
| EMU_HANA_DOCK_LEDS_2_LOCK
);
549 /* Allow DLL to settle */
552 snd_emu1010_fpga_write(emu
, EMU_HANA_UNMUTE
, EMU_UNMUTE
);
557 snd_emu1010_fpga_write(emu
, EMU_HANA_UNMUTE
, EMU_MUTE
);
558 /* Default fallback clock 48kHz */
559 snd_emu1010_fpga_write(emu
, EMU_HANA_DEFCLOCK
, EMU_HANA_DEFCLOCK_48K
);
560 /* Word Clock source, Internal 48kHz x1 */
561 snd_emu1010_fpga_write(emu
, EMU_HANA_WCLOCK
,
562 EMU_HANA_WCLOCK_INT_48K
| EMU_HANA_WCLOCK_1X
);
563 /* Set LEDs on Audio Dock */
564 snd_emu1010_fpga_write(emu
, EMU_HANA_DOCK_LEDS_2
,
565 EMU_HANA_DOCK_LEDS_2_48K
| EMU_HANA_DOCK_LEDS_2_LOCK
);
566 /* Allow DLL to settle */
569 snd_emu1010_fpga_write(emu
, EMU_HANA_UNMUTE
, EMU_UNMUTE
);
576 static struct snd_kcontrol_new snd_emu1010_internal_clock
=
578 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
,
579 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
580 .name
= "Clock Internal Rate",
582 .info
= snd_emu1010_internal_clock_info
,
583 .get
= snd_emu1010_internal_clock_get
,
584 .put
= snd_emu1010_internal_clock_put
587 static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol
*kcontrol
,
588 struct snd_ctl_elem_info
*uinfo
)
591 static char *texts
[4] = {
592 "Unknown1", "Unknown2", "Mic", "Line"
595 static char *texts
[2] = {
599 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
601 uinfo
->value
.enumerated
.items
= 2;
602 if (uinfo
->value
.enumerated
.item
> 1)
603 uinfo
->value
.enumerated
.item
= 1;
604 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
608 static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol
*kcontrol
,
609 struct snd_ctl_elem_value
*ucontrol
)
611 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
613 ucontrol
->value
.enumerated
.item
[0] = emu
->i2c_capture_source
;
617 static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol
*kcontrol
,
618 struct snd_ctl_elem_value
*ucontrol
)
620 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
621 unsigned int source_id
;
622 unsigned int ngain
, ogain
;
627 /* If the capture source has changed,
628 * update the capture volume from the cached value
629 * for the particular source.
631 source_id
= ucontrol
->value
.enumerated
.item
[0]; /* Use 2 and 3 */
632 change
= (emu
->i2c_capture_source
!= source_id
);
634 snd_emu10k1_i2c_write(emu
, ADC_MUX
, 0); /* Mute input */
635 spin_lock_irqsave(&emu
->emu_lock
, flags
);
636 gpio
= inl(emu
->port
+ A_IOCFG
);
638 outl(gpio
| 0x4, emu
->port
+ A_IOCFG
);
640 outl(gpio
& ~0x4, emu
->port
+ A_IOCFG
);
641 spin_unlock_irqrestore(&emu
->emu_lock
, flags
);
643 ngain
= emu
->i2c_capture_volume
[source_id
][0]; /* Left */
644 ogain
= emu
->i2c_capture_volume
[emu
->i2c_capture_source
][0]; /* Left */
646 snd_emu10k1_i2c_write(emu
, ADC_ATTEN_ADCL
, ((ngain
) & 0xff));
647 ngain
= emu
->i2c_capture_volume
[source_id
][1]; /* Right */
648 ogain
= emu
->i2c_capture_volume
[emu
->i2c_capture_source
][1]; /* Right */
650 snd_emu10k1_i2c_write(emu
, ADC_ATTEN_ADCR
, ((ngain
) & 0xff));
652 source
= 1 << (source_id
+ 2);
653 snd_emu10k1_i2c_write(emu
, ADC_MUX
, source
); /* Set source */
654 emu
->i2c_capture_source
= source_id
;
659 static struct snd_kcontrol_new snd_audigy_i2c_capture_source
=
661 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
662 .name
= "Capture Source",
663 .info
= snd_audigy_i2c_capture_source_info
,
664 .get
= snd_audigy_i2c_capture_source_get
,
665 .put
= snd_audigy_i2c_capture_source_put
668 static int snd_audigy_i2c_volume_info(struct snd_kcontrol
*kcontrol
,
669 struct snd_ctl_elem_info
*uinfo
)
671 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
673 uinfo
->value
.integer
.min
= 0;
674 uinfo
->value
.integer
.max
= 255;
678 static int snd_audigy_i2c_volume_get(struct snd_kcontrol
*kcontrol
,
679 struct snd_ctl_elem_value
*ucontrol
)
681 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
684 source_id
= kcontrol
->private_value
;
686 ucontrol
->value
.integer
.value
[0] = emu
->i2c_capture_volume
[source_id
][0];
687 ucontrol
->value
.integer
.value
[1] = emu
->i2c_capture_volume
[source_id
][1];
691 static int snd_audigy_i2c_volume_put(struct snd_kcontrol
*kcontrol
,
692 struct snd_ctl_elem_value
*ucontrol
)
694 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
700 source_id
= kcontrol
->private_value
;
701 ogain
= emu
->i2c_capture_volume
[source_id
][0]; /* Left */
702 ngain
= ucontrol
->value
.integer
.value
[0];
705 if (ogain
!= ngain
) {
706 if (emu
->i2c_capture_source
== source_id
)
707 snd_emu10k1_i2c_write(emu
, ADC_ATTEN_ADCL
, ((ngain
) & 0xff) );
708 emu
->i2c_capture_volume
[source_id
][0] = ucontrol
->value
.integer
.value
[0];
711 ogain
= emu
->i2c_capture_volume
[source_id
][1]; /* Right */
712 ngain
= ucontrol
->value
.integer
.value
[1];
715 if (ogain
!= ngain
) {
716 if (emu
->i2c_capture_source
== source_id
)
717 snd_emu10k1_i2c_write(emu
, ADC_ATTEN_ADCR
, ((ngain
) & 0xff));
718 emu
->i2c_capture_volume
[source_id
][1] = ucontrol
->value
.integer
.value
[1];
725 #define I2C_VOLUME(xname,chid) \
727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
728 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
729 SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
730 .info = snd_audigy_i2c_volume_info, \
731 .get = snd_audigy_i2c_volume_get, \
732 .put = snd_audigy_i2c_volume_put, \
733 .tlv = { .p = snd_audigy_db_scale2 }, \
734 .private_value = chid \
738 static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls
[] __devinitdata
= {
739 I2C_VOLUME("Mic Capture Volume", 0),
740 I2C_VOLUME("Line Capture Volume", 0)
744 static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
746 static char *texts
[] = {"44100", "48000", "96000"};
748 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
750 uinfo
->value
.enumerated
.items
= 3;
751 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
752 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
753 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
757 static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol
*kcontrol
,
758 struct snd_ctl_elem_value
*ucontrol
)
760 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
765 spin_lock_irqsave(&emu
->reg_lock
, flags
);
766 tmp
= snd_emu10k1_ptr_read(emu
, A_SPDIF_SAMPLERATE
, 0);
767 switch (tmp
& A_SPDIF_RATE_MASK
) {
769 ucontrol
->value
.enumerated
.item
[0] = 0;
772 ucontrol
->value
.enumerated
.item
[0] = 1;
775 ucontrol
->value
.enumerated
.item
[0] = 2;
778 ucontrol
->value
.enumerated
.item
[0] = 1;
780 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
784 static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol
*kcontrol
,
785 struct snd_ctl_elem_value
*ucontrol
)
787 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
789 unsigned int reg
, val
, tmp
;
792 switch(ucontrol
->value
.enumerated
.item
[0]) {
808 spin_lock_irqsave(&emu
->reg_lock
, flags
);
809 reg
= snd_emu10k1_ptr_read(emu
, A_SPDIF_SAMPLERATE
, 0);
810 tmp
= reg
& ~A_SPDIF_RATE_MASK
;
812 if ((change
= (tmp
!= reg
)))
813 snd_emu10k1_ptr_write(emu
, A_SPDIF_SAMPLERATE
, 0, tmp
);
814 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
818 static struct snd_kcontrol_new snd_audigy_spdif_output_rate
=
820 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
,
821 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
822 .name
= "Audigy SPDIF Output Sample Rate",
824 .info
= snd_audigy_spdif_output_rate_info
,
825 .get
= snd_audigy_spdif_output_rate_get
,
826 .put
= snd_audigy_spdif_output_rate_put
830 static int snd_emu10k1_spdif_put(struct snd_kcontrol
*kcontrol
,
831 struct snd_ctl_elem_value
*ucontrol
)
833 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
834 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
839 val
= (ucontrol
->value
.iec958
.status
[0] << 0) |
840 (ucontrol
->value
.iec958
.status
[1] << 8) |
841 (ucontrol
->value
.iec958
.status
[2] << 16) |
842 (ucontrol
->value
.iec958
.status
[3] << 24);
843 spin_lock_irqsave(&emu
->reg_lock
, flags
);
844 change
= val
!= emu
->spdif_bits
[idx
];
846 snd_emu10k1_ptr_write(emu
, SPCS0
+ idx
, 0, val
);
847 emu
->spdif_bits
[idx
] = val
;
849 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
853 static struct snd_kcontrol_new snd_emu10k1_spdif_mask_control
=
855 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
856 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
857 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,MASK
),
859 .info
= snd_emu10k1_spdif_info
,
860 .get
= snd_emu10k1_spdif_get_mask
863 static struct snd_kcontrol_new snd_emu10k1_spdif_control
=
865 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
866 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,DEFAULT
),
868 .info
= snd_emu10k1_spdif_info
,
869 .get
= snd_emu10k1_spdif_get
,
870 .put
= snd_emu10k1_spdif_put
874 static void update_emu10k1_fxrt(struct snd_emu10k1
*emu
, int voice
, unsigned char *route
)
877 snd_emu10k1_ptr_write(emu
, A_FXRT1
, voice
,
878 snd_emu10k1_compose_audigy_fxrt1(route
));
879 snd_emu10k1_ptr_write(emu
, A_FXRT2
, voice
,
880 snd_emu10k1_compose_audigy_fxrt2(route
));
882 snd_emu10k1_ptr_write(emu
, FXRT
, voice
,
883 snd_emu10k1_compose_send_routing(route
));
887 static void update_emu10k1_send_volume(struct snd_emu10k1
*emu
, int voice
, unsigned char *volume
)
889 snd_emu10k1_ptr_write(emu
, PTRX_FXSENDAMOUNT_A
, voice
, volume
[0]);
890 snd_emu10k1_ptr_write(emu
, PTRX_FXSENDAMOUNT_B
, voice
, volume
[1]);
891 snd_emu10k1_ptr_write(emu
, PSST_FXSENDAMOUNT_C
, voice
, volume
[2]);
892 snd_emu10k1_ptr_write(emu
, DSL_FXSENDAMOUNT_D
, voice
, volume
[3]);
894 unsigned int val
= ((unsigned int)volume
[4] << 24) |
895 ((unsigned int)volume
[5] << 16) |
896 ((unsigned int)volume
[6] << 8) |
897 (unsigned int)volume
[7];
898 snd_emu10k1_ptr_write(emu
, A_SENDAMOUNTS
, voice
, val
);
902 /* PCM stream controls */
904 static int snd_emu10k1_send_routing_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
906 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
907 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
908 uinfo
->count
= emu
->audigy
? 3*8 : 3*4;
909 uinfo
->value
.integer
.min
= 0;
910 uinfo
->value
.integer
.max
= emu
->audigy
? 0x3f : 0x0f;
914 static int snd_emu10k1_send_routing_get(struct snd_kcontrol
*kcontrol
,
915 struct snd_ctl_elem_value
*ucontrol
)
918 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
919 struct snd_emu10k1_pcm_mixer
*mix
=
920 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
922 int num_efx
= emu
->audigy
? 8 : 4;
923 int mask
= emu
->audigy
? 0x3f : 0x0f;
925 spin_lock_irqsave(&emu
->reg_lock
, flags
);
926 for (voice
= 0; voice
< 3; voice
++)
927 for (idx
= 0; idx
< num_efx
; idx
++)
928 ucontrol
->value
.integer
.value
[(voice
* num_efx
) + idx
] =
929 mix
->send_routing
[voice
][idx
] & mask
;
930 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
934 static int snd_emu10k1_send_routing_put(struct snd_kcontrol
*kcontrol
,
935 struct snd_ctl_elem_value
*ucontrol
)
938 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
939 struct snd_emu10k1_pcm_mixer
*mix
=
940 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
941 int change
= 0, voice
, idx
, val
;
942 int num_efx
= emu
->audigy
? 8 : 4;
943 int mask
= emu
->audigy
? 0x3f : 0x0f;
945 spin_lock_irqsave(&emu
->reg_lock
, flags
);
946 for (voice
= 0; voice
< 3; voice
++)
947 for (idx
= 0; idx
< num_efx
; idx
++) {
948 val
= ucontrol
->value
.integer
.value
[(voice
* num_efx
) + idx
] & mask
;
949 if (mix
->send_routing
[voice
][idx
] != val
) {
950 mix
->send_routing
[voice
][idx
] = val
;
954 if (change
&& mix
->epcm
) {
955 if (mix
->epcm
->voices
[0] && mix
->epcm
->voices
[1]) {
956 update_emu10k1_fxrt(emu
, mix
->epcm
->voices
[0]->number
,
957 &mix
->send_routing
[1][0]);
958 update_emu10k1_fxrt(emu
, mix
->epcm
->voices
[1]->number
,
959 &mix
->send_routing
[2][0]);
960 } else if (mix
->epcm
->voices
[0]) {
961 update_emu10k1_fxrt(emu
, mix
->epcm
->voices
[0]->number
,
962 &mix
->send_routing
[0][0]);
965 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
969 static struct snd_kcontrol_new snd_emu10k1_send_routing_control
=
971 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
972 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
973 .name
= "EMU10K1 PCM Send Routing",
975 .info
= snd_emu10k1_send_routing_info
,
976 .get
= snd_emu10k1_send_routing_get
,
977 .put
= snd_emu10k1_send_routing_put
980 static int snd_emu10k1_send_volume_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
982 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
983 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
984 uinfo
->count
= emu
->audigy
? 3*8 : 3*4;
985 uinfo
->value
.integer
.min
= 0;
986 uinfo
->value
.integer
.max
= 255;
990 static int snd_emu10k1_send_volume_get(struct snd_kcontrol
*kcontrol
,
991 struct snd_ctl_elem_value
*ucontrol
)
994 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
995 struct snd_emu10k1_pcm_mixer
*mix
=
996 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
998 int num_efx
= emu
->audigy
? 8 : 4;
1000 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1001 for (idx
= 0; idx
< 3*num_efx
; idx
++)
1002 ucontrol
->value
.integer
.value
[idx
] = mix
->send_volume
[idx
/num_efx
][idx
%num_efx
];
1003 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1007 static int snd_emu10k1_send_volume_put(struct snd_kcontrol
*kcontrol
,
1008 struct snd_ctl_elem_value
*ucontrol
)
1010 unsigned long flags
;
1011 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1012 struct snd_emu10k1_pcm_mixer
*mix
=
1013 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1014 int change
= 0, idx
, val
;
1015 int num_efx
= emu
->audigy
? 8 : 4;
1017 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1018 for (idx
= 0; idx
< 3*num_efx
; idx
++) {
1019 val
= ucontrol
->value
.integer
.value
[idx
] & 255;
1020 if (mix
->send_volume
[idx
/num_efx
][idx
%num_efx
] != val
) {
1021 mix
->send_volume
[idx
/num_efx
][idx
%num_efx
] = val
;
1025 if (change
&& mix
->epcm
) {
1026 if (mix
->epcm
->voices
[0] && mix
->epcm
->voices
[1]) {
1027 update_emu10k1_send_volume(emu
, mix
->epcm
->voices
[0]->number
,
1028 &mix
->send_volume
[1][0]);
1029 update_emu10k1_send_volume(emu
, mix
->epcm
->voices
[1]->number
,
1030 &mix
->send_volume
[2][0]);
1031 } else if (mix
->epcm
->voices
[0]) {
1032 update_emu10k1_send_volume(emu
, mix
->epcm
->voices
[0]->number
,
1033 &mix
->send_volume
[0][0]);
1036 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1040 static struct snd_kcontrol_new snd_emu10k1_send_volume_control
=
1042 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1043 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1044 .name
= "EMU10K1 PCM Send Volume",
1046 .info
= snd_emu10k1_send_volume_info
,
1047 .get
= snd_emu10k1_send_volume_get
,
1048 .put
= snd_emu10k1_send_volume_put
1051 static int snd_emu10k1_attn_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1053 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
1055 uinfo
->value
.integer
.min
= 0;
1056 uinfo
->value
.integer
.max
= 0xffff;
1060 static int snd_emu10k1_attn_get(struct snd_kcontrol
*kcontrol
,
1061 struct snd_ctl_elem_value
*ucontrol
)
1063 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1064 struct snd_emu10k1_pcm_mixer
*mix
=
1065 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1066 unsigned long flags
;
1069 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1070 for (idx
= 0; idx
< 3; idx
++)
1071 ucontrol
->value
.integer
.value
[idx
] = mix
->attn
[idx
];
1072 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1076 static int snd_emu10k1_attn_put(struct snd_kcontrol
*kcontrol
,
1077 struct snd_ctl_elem_value
*ucontrol
)
1079 unsigned long flags
;
1080 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1081 struct snd_emu10k1_pcm_mixer
*mix
=
1082 &emu
->pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1083 int change
= 0, idx
, val
;
1085 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1086 for (idx
= 0; idx
< 3; idx
++) {
1087 val
= ucontrol
->value
.integer
.value
[idx
] & 0xffff;
1088 if (mix
->attn
[idx
] != val
) {
1089 mix
->attn
[idx
] = val
;
1093 if (change
&& mix
->epcm
) {
1094 if (mix
->epcm
->voices
[0] && mix
->epcm
->voices
[1]) {
1095 snd_emu10k1_ptr_write(emu
, VTFT_VOLUMETARGET
, mix
->epcm
->voices
[0]->number
, mix
->attn
[1]);
1096 snd_emu10k1_ptr_write(emu
, VTFT_VOLUMETARGET
, mix
->epcm
->voices
[1]->number
, mix
->attn
[2]);
1097 } else if (mix
->epcm
->voices
[0]) {
1098 snd_emu10k1_ptr_write(emu
, VTFT_VOLUMETARGET
, mix
->epcm
->voices
[0]->number
, mix
->attn
[0]);
1101 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1105 static struct snd_kcontrol_new snd_emu10k1_attn_control
=
1107 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1108 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1109 .name
= "EMU10K1 PCM Volume",
1111 .info
= snd_emu10k1_attn_info
,
1112 .get
= snd_emu10k1_attn_get
,
1113 .put
= snd_emu10k1_attn_put
1116 /* Mutichannel PCM stream controls */
1118 static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1120 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1121 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
1122 uinfo
->count
= emu
->audigy
? 8 : 4;
1123 uinfo
->value
.integer
.min
= 0;
1124 uinfo
->value
.integer
.max
= emu
->audigy
? 0x3f : 0x0f;
1128 static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol
*kcontrol
,
1129 struct snd_ctl_elem_value
*ucontrol
)
1131 unsigned long flags
;
1132 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1133 struct snd_emu10k1_pcm_mixer
*mix
=
1134 &emu
->efx_pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1136 int num_efx
= emu
->audigy
? 8 : 4;
1137 int mask
= emu
->audigy
? 0x3f : 0x0f;
1139 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1140 for (idx
= 0; idx
< num_efx
; idx
++)
1141 ucontrol
->value
.integer
.value
[idx
] =
1142 mix
->send_routing
[0][idx
] & mask
;
1143 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1147 static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol
*kcontrol
,
1148 struct snd_ctl_elem_value
*ucontrol
)
1150 unsigned long flags
;
1151 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1152 int ch
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1153 struct snd_emu10k1_pcm_mixer
*mix
= &emu
->efx_pcm_mixer
[ch
];
1154 int change
= 0, idx
, val
;
1155 int num_efx
= emu
->audigy
? 8 : 4;
1156 int mask
= emu
->audigy
? 0x3f : 0x0f;
1158 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1159 for (idx
= 0; idx
< num_efx
; idx
++) {
1160 val
= ucontrol
->value
.integer
.value
[idx
] & mask
;
1161 if (mix
->send_routing
[0][idx
] != val
) {
1162 mix
->send_routing
[0][idx
] = val
;
1167 if (change
&& mix
->epcm
) {
1168 if (mix
->epcm
->voices
[ch
]) {
1169 update_emu10k1_fxrt(emu
, mix
->epcm
->voices
[ch
]->number
,
1170 &mix
->send_routing
[0][0]);
1173 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1177 static struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control
=
1179 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1180 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1181 .name
= "Multichannel PCM Send Routing",
1183 .info
= snd_emu10k1_efx_send_routing_info
,
1184 .get
= snd_emu10k1_efx_send_routing_get
,
1185 .put
= snd_emu10k1_efx_send_routing_put
1188 static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1190 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1191 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
1192 uinfo
->count
= emu
->audigy
? 8 : 4;
1193 uinfo
->value
.integer
.min
= 0;
1194 uinfo
->value
.integer
.max
= 255;
1198 static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol
*kcontrol
,
1199 struct snd_ctl_elem_value
*ucontrol
)
1201 unsigned long flags
;
1202 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1203 struct snd_emu10k1_pcm_mixer
*mix
=
1204 &emu
->efx_pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1206 int num_efx
= emu
->audigy
? 8 : 4;
1208 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1209 for (idx
= 0; idx
< num_efx
; idx
++)
1210 ucontrol
->value
.integer
.value
[idx
] = mix
->send_volume
[0][idx
];
1211 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1215 static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol
*kcontrol
,
1216 struct snd_ctl_elem_value
*ucontrol
)
1218 unsigned long flags
;
1219 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1220 int ch
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1221 struct snd_emu10k1_pcm_mixer
*mix
= &emu
->efx_pcm_mixer
[ch
];
1222 int change
= 0, idx
, val
;
1223 int num_efx
= emu
->audigy
? 8 : 4;
1225 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1226 for (idx
= 0; idx
< num_efx
; idx
++) {
1227 val
= ucontrol
->value
.integer
.value
[idx
] & 255;
1228 if (mix
->send_volume
[0][idx
] != val
) {
1229 mix
->send_volume
[0][idx
] = val
;
1233 if (change
&& mix
->epcm
) {
1234 if (mix
->epcm
->voices
[ch
]) {
1235 update_emu10k1_send_volume(emu
, mix
->epcm
->voices
[ch
]->number
,
1236 &mix
->send_volume
[0][0]);
1239 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1244 static struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control
=
1246 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1247 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1248 .name
= "Multichannel PCM Send Volume",
1250 .info
= snd_emu10k1_efx_send_volume_info
,
1251 .get
= snd_emu10k1_efx_send_volume_get
,
1252 .put
= snd_emu10k1_efx_send_volume_put
1255 static int snd_emu10k1_efx_attn_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1257 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
1259 uinfo
->value
.integer
.min
= 0;
1260 uinfo
->value
.integer
.max
= 0xffff;
1264 static int snd_emu10k1_efx_attn_get(struct snd_kcontrol
*kcontrol
,
1265 struct snd_ctl_elem_value
*ucontrol
)
1267 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1268 struct snd_emu10k1_pcm_mixer
*mix
=
1269 &emu
->efx_pcm_mixer
[snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
)];
1270 unsigned long flags
;
1272 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1273 ucontrol
->value
.integer
.value
[0] = mix
->attn
[0];
1274 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1278 static int snd_emu10k1_efx_attn_put(struct snd_kcontrol
*kcontrol
,
1279 struct snd_ctl_elem_value
*ucontrol
)
1281 unsigned long flags
;
1282 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1283 int ch
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1284 struct snd_emu10k1_pcm_mixer
*mix
= &emu
->efx_pcm_mixer
[ch
];
1285 int change
= 0, val
;
1287 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1288 val
= ucontrol
->value
.integer
.value
[0] & 0xffff;
1289 if (mix
->attn
[0] != val
) {
1293 if (change
&& mix
->epcm
) {
1294 if (mix
->epcm
->voices
[ch
]) {
1295 snd_emu10k1_ptr_write(emu
, VTFT_VOLUMETARGET
, mix
->epcm
->voices
[ch
]->number
, mix
->attn
[0]);
1298 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1302 static struct snd_kcontrol_new snd_emu10k1_efx_attn_control
=
1304 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1305 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1306 .name
= "Multichannel PCM Volume",
1308 .info
= snd_emu10k1_efx_attn_info
,
1309 .get
= snd_emu10k1_efx_attn_get
,
1310 .put
= snd_emu10k1_efx_attn_put
1313 static int snd_emu10k1_shared_spdif_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1315 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
1317 uinfo
->value
.integer
.min
= 0;
1318 uinfo
->value
.integer
.max
= 1;
1322 static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol
*kcontrol
,
1323 struct snd_ctl_elem_value
*ucontrol
)
1325 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1328 ucontrol
->value
.integer
.value
[0] = inl(emu
->port
+ A_IOCFG
) & A_IOCFG_GPOUT0
? 1 : 0;
1330 ucontrol
->value
.integer
.value
[0] = inl(emu
->port
+ HCFG
) & HCFG_GPOUT0
? 1 : 0;
1334 static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol
*kcontrol
,
1335 struct snd_ctl_elem_value
*ucontrol
)
1337 unsigned long flags
;
1338 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1339 unsigned int reg
, val
;
1342 spin_lock_irqsave(&emu
->reg_lock
, flags
);
1343 if ( emu
->card_capabilities
->i2c_adc
) {
1344 /* Do nothing for Audigy 2 ZS Notebook */
1345 } else if (emu
->audigy
) {
1346 reg
= inl(emu
->port
+ A_IOCFG
);
1347 val
= ucontrol
->value
.integer
.value
[0] ? A_IOCFG_GPOUT0
: 0;
1348 change
= (reg
& A_IOCFG_GPOUT0
) != val
;
1350 reg
&= ~A_IOCFG_GPOUT0
;
1352 outl(reg
| val
, emu
->port
+ A_IOCFG
);
1355 reg
= inl(emu
->port
+ HCFG
);
1356 val
= ucontrol
->value
.integer
.value
[0] ? HCFG_GPOUT0
: 0;
1357 change
|= (reg
& HCFG_GPOUT0
) != val
;
1359 reg
&= ~HCFG_GPOUT0
;
1361 outl(reg
| val
, emu
->port
+ HCFG
);
1363 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
1367 static struct snd_kcontrol_new snd_emu10k1_shared_spdif __devinitdata
=
1369 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1370 .name
= "SB Live Analog/Digital Output Jack",
1371 .info
= snd_emu10k1_shared_spdif_info
,
1372 .get
= snd_emu10k1_shared_spdif_get
,
1373 .put
= snd_emu10k1_shared_spdif_put
1376 static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata
=
1378 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1379 .name
= "Audigy Analog/Digital Output Jack",
1380 .info
= snd_emu10k1_shared_spdif_info
,
1381 .get
= snd_emu10k1_shared_spdif_get
,
1382 .put
= snd_emu10k1_shared_spdif_put
1387 static void snd_emu10k1_mixer_free_ac97(struct snd_ac97
*ac97
)
1389 struct snd_emu10k1
*emu
= ac97
->private_data
;
1395 static int remove_ctl(struct snd_card
*card
, const char *name
)
1397 struct snd_ctl_elem_id id
;
1398 memset(&id
, 0, sizeof(id
));
1399 strcpy(id
.name
, name
);
1400 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1401 return snd_ctl_remove_id(card
, &id
);
1404 static struct snd_kcontrol
*ctl_find(struct snd_card
*card
, const char *name
)
1406 struct snd_ctl_elem_id sid
;
1407 memset(&sid
, 0, sizeof(sid
));
1408 strcpy(sid
.name
, name
);
1409 sid
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1410 return snd_ctl_find_id(card
, &sid
);
1413 static int rename_ctl(struct snd_card
*card
, const char *src
, const char *dst
)
1415 struct snd_kcontrol
*kctl
= ctl_find(card
, src
);
1417 strcpy(kctl
->id
.name
, dst
);
1423 int __devinit
snd_emu10k1_mixer(struct snd_emu10k1
*emu
,
1424 int pcm_device
, int multi_device
)
1427 struct snd_kcontrol
*kctl
;
1428 struct snd_card
*card
= emu
->card
;
1430 static char *emu10k1_remove_ctls
[] = {
1431 /* no AC97 mono, surround, center/lfe */
1432 "Master Mono Playback Switch",
1433 "Master Mono Playback Volume",
1434 "PCM Out Path & Mute",
1435 "Mono Output Select",
1436 "Front Playback Switch",
1437 "Front Playback Volume",
1438 "Surround Playback Switch",
1439 "Surround Playback Volume",
1440 "Center Playback Switch",
1441 "Center Playback Volume",
1442 "LFE Playback Switch",
1443 "LFE Playback Volume",
1446 static char *emu10k1_rename_ctls
[] = {
1447 "Surround Digital Playback Volume", "Surround Playback Volume",
1448 "Center Digital Playback Volume", "Center Playback Volume",
1449 "LFE Digital Playback Volume", "LFE Playback Volume",
1452 static char *audigy_remove_ctls
[] = {
1453 /* Master/PCM controls on ac97 of Audigy has no effect */
1454 /* On the Audigy2 the AC97 playback is piped into
1455 * the Philips ADC for 24bit capture */
1456 "PCM Playback Switch",
1457 "PCM Playback Volume",
1458 "Master Mono Playback Switch",
1459 "Master Mono Playback Volume",
1460 "Master Playback Switch",
1461 "Master Playback Volume",
1462 "PCM Out Path & Mute",
1463 "Mono Output Select",
1464 /* remove unused AC97 capture controls */
1469 "Video Playback Switch",
1470 "Video Playback Volume",
1471 "Mic Playback Switch",
1472 "Mic Playback Volume",
1475 static char *audigy_rename_ctls
[] = {
1476 /* use conventional names */
1477 "Wave Playback Volume", "PCM Playback Volume",
1478 /* "Wave Capture Volume", "PCM Capture Volume", */
1479 "Wave Master Playback Volume", "Master Playback Volume",
1480 "AMic Playback Volume", "Mic Playback Volume",
1483 static char *audigy_rename_ctls_i2c_adc
[] = {
1484 //"Analog Mix Capture Volume","OLD Analog Mix Capture Volume",
1485 "Line Capture Volume", "Analog Mix Capture Volume",
1486 "Wave Playback Volume", "OLD PCM Playback Volume",
1487 "Wave Master Playback Volume", "Master Playback Volume",
1488 "AMic Playback Volume", "Old Mic Playback Volume",
1489 "CD Capture Volume", "IEC958 Optical Capture Volume",
1492 static char *audigy_remove_ctls_i2c_adc
[] = {
1493 /* On the Audigy2 ZS Notebook
1494 * Capture via WM8775 */
1495 "Mic Capture Volume",
1496 "Analog Mix Capture Volume",
1497 "Aux Capture Volume",
1498 "IEC958 Optical Capture Volume",
1501 static char *audigy_remove_ctls_1361t_adc
[] = {
1502 /* On the Audigy2 the AC97 playback is piped into
1503 * the Philips ADC for 24bit capture */
1504 "PCM Playback Switch",
1505 "PCM Playback Volume",
1506 "Master Mono Playback Switch",
1507 "Master Mono Playback Volume",
1511 "Mic Capture Volume",
1512 "Headphone Playback Switch",
1513 "Headphone Playback Volume",
1514 "3D Control - Center",
1515 "3D Control - Depth",
1516 "3D Control - Switch",
1517 "Line2 Playback Volume",
1518 "Line2 Capture Volume",
1521 static char *audigy_rename_ctls_1361t_adc
[] = {
1522 "Master Playback Switch", "Master Capture Switch",
1523 "Master Playback Volume", "Master Capture Volume",
1524 "Wave Master Playback Volume", "Master Playback Volume",
1525 "PC Speaker Playback Switch", "PC Speaker Capture Switch",
1526 "PC Speaker Playback Volume", "PC Speaker Capture Volume",
1527 "Phone Playback Switch", "Phone Capture Switch",
1528 "Phone Playback Volume", "Phone Capture Volume",
1529 "Mic Playback Switch", "Mic Capture Switch",
1530 "Mic Playback Volume", "Mic Capture Volume",
1531 "Line Playback Switch", "Line Capture Switch",
1532 "Line Playback Volume", "Line Capture Volume",
1533 "CD Playback Switch", "CD Capture Switch",
1534 "CD Playback Volume", "CD Capture Volume",
1535 "Aux Playback Switch", "Aux Capture Switch",
1536 "Aux Playback Volume", "Aux Capture Volume",
1537 "Video Playback Switch", "Video Capture Switch",
1538 "Video Playback Volume", "Video Capture Volume",
1543 if (emu
->card_capabilities
->ac97_chip
) {
1544 struct snd_ac97_bus
*pbus
;
1545 struct snd_ac97_template ac97
;
1546 static struct snd_ac97_bus_ops ops
= {
1547 .write
= snd_emu10k1_ac97_write
,
1548 .read
= snd_emu10k1_ac97_read
,
1551 if ((err
= snd_ac97_bus(emu
->card
, 0, &ops
, NULL
, &pbus
)) < 0)
1553 pbus
->no_vra
= 1; /* we don't need VRA */
1555 memset(&ac97
, 0, sizeof(ac97
));
1556 ac97
.private_data
= emu
;
1557 ac97
.private_free
= snd_emu10k1_mixer_free_ac97
;
1558 ac97
.scaps
= AC97_SCAP_NO_SPDIF
;
1559 if ((err
= snd_ac97_mixer(pbus
, &ac97
, &emu
->ac97
)) < 0) {
1560 if (emu
->card_capabilities
->ac97_chip
== 1)
1562 snd_printd(KERN_INFO
"emu10k1: AC97 is optional on this board\n");
1563 snd_printd(KERN_INFO
" Proceeding without ac97 mixers...\n");
1564 snd_device_free(emu
->card
, pbus
);
1565 goto no_ac97
; /* FIXME: get rid of ugly gotos.. */
1568 /* set master volume to 0 dB */
1569 snd_ac97_write_cache(emu
->ac97
, AC97_MASTER
, 0x0000);
1570 /* set capture source to mic */
1571 snd_ac97_write_cache(emu
->ac97
, AC97_REC_SEL
, 0x0000);
1572 if (emu
->card_capabilities
->adc_1361t
)
1573 c
= audigy_remove_ctls_1361t_adc
;
1575 c
= audigy_remove_ctls
;
1578 * Credits for cards based on STAC9758:
1579 * James Courtier-Dutton <James@superbug.demon.co.uk>
1580 * Voluspa <voluspa@comhem.se>
1582 if (emu
->ac97
->id
== AC97_ID_STAC9758
) {
1584 snd_emu10k1_ptr_write(emu
, AC97SLOT
, 0, AC97SLOT_CNTR
|AC97SLOT_LFE
|AC97SLOT_REAR_LEFT
|AC97SLOT_REAR_RIGHT
);
1585 snd_ac97_write_cache(emu
->ac97
, AC97_HEADPHONE
, 0x0202);
1587 /* remove unused AC97 controls */
1588 snd_ac97_write_cache(emu
->ac97
, AC97_SURROUND_MASTER
, 0x0202);
1589 snd_ac97_write_cache(emu
->ac97
, AC97_CENTER_LFE_MASTER
, 0x0202);
1590 c
= emu10k1_remove_ctls
;
1593 remove_ctl(card
, *c
);
1594 } else if (emu
->card_capabilities
->i2c_adc
) {
1595 c
= audigy_remove_ctls_i2c_adc
;
1597 remove_ctl(card
, *c
);
1600 if (emu
->card_capabilities
->ecard
)
1601 strcpy(emu
->card
->mixername
, "EMU APS");
1602 else if (emu
->audigy
)
1603 strcpy(emu
->card
->mixername
, "SB Audigy");
1605 strcpy(emu
->card
->mixername
, "Emu10k1");
1609 if (emu
->card_capabilities
->adc_1361t
)
1610 c
= audigy_rename_ctls_1361t_adc
;
1611 else if (emu
->card_capabilities
->i2c_adc
)
1612 c
= audigy_rename_ctls_i2c_adc
;
1614 c
= audigy_rename_ctls
;
1616 c
= emu10k1_rename_ctls
;
1618 rename_ctl(card
, c
[0], c
[1]);
1620 if (emu
->card_capabilities
->subsystem
== 0x20071102) { /* Audigy 4 Pro */
1621 rename_ctl(card
, "Line2 Capture Volume", "Line1/Mic Capture Volume");
1622 rename_ctl(card
, "Analog Mix Capture Volume", "Line2 Capture Volume");
1623 rename_ctl(card
, "Aux2 Capture Volume", "Line3 Capture Volume");
1624 rename_ctl(card
, "Mic Capture Volume", "Unknown1 Capture Volume");
1625 remove_ctl(card
, "Headphone Playback Switch");
1626 remove_ctl(card
, "Headphone Playback Volume");
1627 remove_ctl(card
, "3D Control - Center");
1628 remove_ctl(card
, "3D Control - Depth");
1629 remove_ctl(card
, "3D Control - Switch");
1631 if ((kctl
= emu
->ctl_send_routing
= snd_ctl_new1(&snd_emu10k1_send_routing_control
, emu
)) == NULL
)
1633 kctl
->id
.device
= pcm_device
;
1634 if ((err
= snd_ctl_add(card
, kctl
)))
1636 if ((kctl
= emu
->ctl_send_volume
= snd_ctl_new1(&snd_emu10k1_send_volume_control
, emu
)) == NULL
)
1638 kctl
->id
.device
= pcm_device
;
1639 if ((err
= snd_ctl_add(card
, kctl
)))
1641 if ((kctl
= emu
->ctl_attn
= snd_ctl_new1(&snd_emu10k1_attn_control
, emu
)) == NULL
)
1643 kctl
->id
.device
= pcm_device
;
1644 if ((err
= snd_ctl_add(card
, kctl
)))
1647 if ((kctl
= emu
->ctl_efx_send_routing
= snd_ctl_new1(&snd_emu10k1_efx_send_routing_control
, emu
)) == NULL
)
1649 kctl
->id
.device
= multi_device
;
1650 if ((err
= snd_ctl_add(card
, kctl
)))
1653 if ((kctl
= emu
->ctl_efx_send_volume
= snd_ctl_new1(&snd_emu10k1_efx_send_volume_control
, emu
)) == NULL
)
1655 kctl
->id
.device
= multi_device
;
1656 if ((err
= snd_ctl_add(card
, kctl
)))
1659 if ((kctl
= emu
->ctl_efx_attn
= snd_ctl_new1(&snd_emu10k1_efx_attn_control
, emu
)) == NULL
)
1661 kctl
->id
.device
= multi_device
;
1662 if ((err
= snd_ctl_add(card
, kctl
)))
1665 /* initialize the routing and volume table for each pcm playback stream */
1666 for (pcm
= 0; pcm
< 32; pcm
++) {
1667 struct snd_emu10k1_pcm_mixer
*mix
;
1670 mix
= &emu
->pcm_mixer
[pcm
];
1673 for (v
= 0; v
< 4; v
++)
1674 mix
->send_routing
[0][v
] =
1675 mix
->send_routing
[1][v
] =
1676 mix
->send_routing
[2][v
] = v
;
1678 memset(&mix
->send_volume
, 0, sizeof(mix
->send_volume
));
1679 mix
->send_volume
[0][0] = mix
->send_volume
[0][1] =
1680 mix
->send_volume
[1][0] = mix
->send_volume
[2][1] = 255;
1682 mix
->attn
[0] = mix
->attn
[1] = mix
->attn
[2] = 0xffff;
1685 /* initialize the routing and volume table for the multichannel playback stream */
1686 for (pcm
= 0; pcm
< NUM_EFX_PLAYBACK
; pcm
++) {
1687 struct snd_emu10k1_pcm_mixer
*mix
;
1690 mix
= &emu
->efx_pcm_mixer
[pcm
];
1693 mix
->send_routing
[0][0] = pcm
;
1694 mix
->send_routing
[0][1] = (pcm
== 0) ? 1 : 0;
1695 for (v
= 0; v
< 2; v
++)
1696 mix
->send_routing
[0][2+v
] = 13+v
;
1698 for (v
= 0; v
< 4; v
++)
1699 mix
->send_routing
[0][4+v
] = 60+v
;
1701 memset(&mix
->send_volume
, 0, sizeof(mix
->send_volume
));
1702 mix
->send_volume
[0][0] = 255;
1704 mix
->attn
[0] = 0xffff;
1707 if (! emu
->card_capabilities
->ecard
) { /* FIXME: APS has these controls? */
1708 /* sb live! and audigy */
1709 if ((kctl
= snd_ctl_new1(&snd_emu10k1_spdif_mask_control
, emu
)) == NULL
)
1712 kctl
->id
.device
= emu
->pcm_efx
->device
;
1713 if ((err
= snd_ctl_add(card
, kctl
)))
1715 if ((kctl
= snd_ctl_new1(&snd_emu10k1_spdif_control
, emu
)) == NULL
)
1718 kctl
->id
.device
= emu
->pcm_efx
->device
;
1719 if ((err
= snd_ctl_add(card
, kctl
)))
1723 if ( emu
->card_capabilities
->emu1010
) {
1724 ; /* Disable the snd_audigy_spdif_shared_spdif */
1725 } else if (emu
->audigy
) {
1726 if ((kctl
= snd_ctl_new1(&snd_audigy_shared_spdif
, emu
)) == NULL
)
1728 if ((err
= snd_ctl_add(card
, kctl
)))
1731 if ((kctl
= snd_ctl_new1(&snd_audigy_spdif_output_rate
, emu
)) == NULL
)
1733 if ((err
= snd_ctl_add(card
, kctl
)))
1736 } else if (! emu
->card_capabilities
->ecard
) {
1738 if ((kctl
= snd_ctl_new1(&snd_emu10k1_shared_spdif
, emu
)) == NULL
)
1740 if ((err
= snd_ctl_add(card
, kctl
)))
1743 if (emu
->card_capabilities
->ca0151_chip
) { /* P16V */
1744 if ((err
= snd_p16v_mixer(emu
)))
1748 if ( emu
->card_capabilities
->emu1010
) {
1751 for (i
= 0; i
< ARRAY_SIZE(snd_emu1010_output_enum_ctls
); i
++) {
1752 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_emu1010_output_enum_ctls
[i
], emu
));
1756 for (i
= 0; i
< ARRAY_SIZE(snd_emu1010_input_enum_ctls
); i
++) {
1757 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_emu1010_input_enum_ctls
[i
], emu
));
1761 for (i
= 0; i
< ARRAY_SIZE(snd_emu1010_adc_pads
); i
++) {
1762 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_emu1010_adc_pads
[i
], emu
));
1766 for (i
= 0; i
< ARRAY_SIZE(snd_emu1010_dac_pads
); i
++) {
1767 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_emu1010_dac_pads
[i
], emu
));
1771 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_emu1010_internal_clock
, emu
));
1776 if ( emu
->card_capabilities
->i2c_adc
) {
1779 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_audigy_i2c_capture_source
, emu
));
1783 for (i
= 0; i
< ARRAY_SIZE(snd_audigy_i2c_volume_ctls
); i
++) {
1784 err
= snd_ctl_add(card
, snd_ctl_new1(&snd_audigy_i2c_volume_ctls
[i
], emu
));