1 | /*
|
---|
2 | * ALSA driver for ICEnsemble ICE1712 (Envy24)
|
---|
3 | *
|
---|
4 | * Lowlevel functions for M-Audio Delta 1010, 44, 66, Dio2496, Audiophile
|
---|
5 | *
|
---|
6 | * Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
|
---|
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 |
|
---|
24 | #include <sound/driver.h>
|
---|
25 | #include <asm/io.h>
|
---|
26 | #include <linux/delay.h>
|
---|
27 | #include <linux/interrupt.h>
|
---|
28 | #include <linux/init.h>
|
---|
29 | #include <linux/slab.h>
|
---|
30 | #include <sound/core.h>
|
---|
31 | #include <sound/cs8427.h>
|
---|
32 | #include <sound/asoundef.h>
|
---|
33 |
|
---|
34 | #include "ice1712.h"
|
---|
35 | #include "delta.h"
|
---|
36 |
|
---|
37 | #define SND_CS8403
|
---|
38 | #include <sound/cs8403.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * CS8427 via SPI mode (for Audiophile), emulated I2C
|
---|
43 | */
|
---|
44 |
|
---|
45 | /* send 8 bits */
|
---|
46 | static void ap_cs8427_write_byte(ice1712_t *ice, unsigned char data, unsigned char tmp)
|
---|
47 | {
|
---|
48 | int idx;
|
---|
49 |
|
---|
50 | for (idx = 7; idx >= 0; idx--) {
|
---|
51 | tmp &= ~(ICE1712_DELTA_AP_DOUT|ICE1712_DELTA_AP_CCLK);
|
---|
52 | if (data & (1 << idx))
|
---|
53 | tmp |= ICE1712_DELTA_AP_DOUT;
|
---|
54 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
55 | udelay(5);
|
---|
56 | tmp |= ICE1712_DELTA_AP_CCLK;
|
---|
57 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
58 | udelay(5);
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | /* read 8 bits */
|
---|
63 | static unsigned char ap_cs8427_read_byte(ice1712_t *ice, unsigned char tmp)
|
---|
64 | {
|
---|
65 | unsigned char data = 0;
|
---|
66 | int idx;
|
---|
67 |
|
---|
68 | for (idx = 7; idx >= 0; idx--) {
|
---|
69 | tmp &= ~ICE1712_DELTA_AP_CCLK;
|
---|
70 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
71 | udelay(5);
|
---|
72 | if (snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_DELTA_AP_DIN)
|
---|
73 | data |= 1 << idx;
|
---|
74 | tmp |= ICE1712_DELTA_AP_CCLK;
|
---|
75 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
76 | udelay(5);
|
---|
77 | }
|
---|
78 | return data;
|
---|
79 | }
|
---|
80 |
|
---|
81 | /* assert chip select */
|
---|
82 | static unsigned char ap_cs8427_codec_select(ice1712_t *ice)
|
---|
83 | {
|
---|
84 | unsigned char tmp;
|
---|
85 | tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
|
---|
86 | if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010LT) {
|
---|
87 | tmp &= ~ICE1712_DELTA_1010LT_CS;
|
---|
88 | tmp |= ICE1712_DELTA_1010LT_CCLK | ICE1712_DELTA_1010LT_CS_CS8427;
|
---|
89 | } else { /* Audiophile */
|
---|
90 | tmp |= ICE1712_DELTA_AP_CCLK | ICE1712_DELTA_AP_CS_CODEC;
|
---|
91 | tmp &= ~ICE1712_DELTA_AP_CS_DIGITAL;
|
---|
92 | }
|
---|
93 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
94 | udelay(5);
|
---|
95 | return tmp;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /* deassert chip select */
|
---|
99 | static void ap_cs8427_codec_deassert(ice1712_t *ice, unsigned char tmp)
|
---|
100 | {
|
---|
101 | if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010LT) {
|
---|
102 | tmp &= ~ICE1712_DELTA_1010LT_CS;
|
---|
103 | tmp |= ICE1712_DELTA_1010LT_CS_NONE;
|
---|
104 | } else { /* Audiophile */
|
---|
105 | tmp |= ICE1712_DELTA_AP_CS_DIGITAL;
|
---|
106 | }
|
---|
107 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /* sequential write */
|
---|
111 | static int ap_cs8427_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
|
---|
112 | {
|
---|
113 | ice1712_t *ice = snd_magic_cast(ice1712_t, device->bus->private_data, return -EIO);
|
---|
114 | int res = count;
|
---|
115 | unsigned char tmp;
|
---|
116 |
|
---|
117 | down(&ice->gpio_mutex);
|
---|
118 | tmp = ap_cs8427_codec_select(ice);
|
---|
119 | ap_cs8427_write_byte(ice, (device->addr << 1) | 0, tmp); /* address + write mode */
|
---|
120 | while (count-- > 0)
|
---|
121 | ap_cs8427_write_byte(ice, *bytes++, tmp);
|
---|
122 | ap_cs8427_codec_deassert(ice, tmp);
|
---|
123 | up(&ice->gpio_mutex);
|
---|
124 | return res;
|
---|
125 | }
|
---|
126 |
|
---|
127 | /* sequential read */
|
---|
128 | static int ap_cs8427_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
|
---|
129 | {
|
---|
130 | ice1712_t *ice = snd_magic_cast(ice1712_t, device->bus->private_data, return -EIO);
|
---|
131 | int res = count;
|
---|
132 | unsigned char tmp;
|
---|
133 |
|
---|
134 | down(&ice->gpio_mutex);
|
---|
135 | tmp = ap_cs8427_codec_select(ice);
|
---|
136 | ap_cs8427_write_byte(ice, (device->addr << 1) | 1, tmp); /* address + read mode */
|
---|
137 | while (count-- > 0)
|
---|
138 | *bytes++ = ap_cs8427_read_byte(ice, tmp);
|
---|
139 | ap_cs8427_codec_deassert(ice, tmp);
|
---|
140 | up(&ice->gpio_mutex);
|
---|
141 | return res;
|
---|
142 | }
|
---|
143 |
|
---|
144 | static int ap_cs8427_probeaddr(snd_i2c_bus_t *bus, unsigned short addr)
|
---|
145 | {
|
---|
146 | if (addr == 0x10)
|
---|
147 | return 1;
|
---|
148 | return -ENOENT;
|
---|
149 | }
|
---|
150 |
|
---|
151 | static snd_i2c_ops_t ap_cs8427_i2c_ops = {
|
---|
152 | .sendbytes = ap_cs8427_sendbytes,
|
---|
153 | .readbytes = ap_cs8427_readbytes,
|
---|
154 | .probeaddr = ap_cs8427_probeaddr,
|
---|
155 | };
|
---|
156 |
|
---|
157 | /*
|
---|
158 | */
|
---|
159 |
|
---|
160 | static void snd_ice1712_delta_cs8403_spdif_write(ice1712_t *ice, unsigned char bits)
|
---|
161 | {
|
---|
162 | unsigned char tmp, mask1, mask2;
|
---|
163 | int idx;
|
---|
164 | /* send byte to transmitter */
|
---|
165 | mask1 = ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK;
|
---|
166 | mask2 = ICE1712_DELTA_SPDIF_OUT_STAT_DATA;
|
---|
167 | down(&ice->gpio_mutex);
|
---|
168 | tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
|
---|
169 | for (idx = 7; idx >= 0; idx--) {
|
---|
170 | tmp &= ~(mask1 | mask2);
|
---|
171 | if (bits & (1 << idx))
|
---|
172 | tmp |= mask2;
|
---|
173 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
174 | udelay(100);
|
---|
175 | tmp |= mask1;
|
---|
176 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
177 | udelay(100);
|
---|
178 | }
|
---|
179 | tmp &= ~mask1;
|
---|
180 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
181 | up(&ice->gpio_mutex);
|
---|
182 | }
|
---|
183 |
|
---|
184 |
|
---|
185 | static void delta_spdif_default_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol)
|
---|
186 | {
|
---|
187 | snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_bits);
|
---|
188 | }
|
---|
189 |
|
---|
190 | static int delta_spdif_default_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol)
|
---|
191 | {
|
---|
192 | unsigned int val;
|
---|
193 | int change;
|
---|
194 |
|
---|
195 | val = snd_cs8403_encode_spdif_bits(&ucontrol->value.iec958);
|
---|
196 | spin_lock_irq(&ice->reg_lock);
|
---|
197 | change = ice->spdif.cs8403_bits != val;
|
---|
198 | ice->spdif.cs8403_bits = val;
|
---|
199 | if (change && ice->playback_pro_substream == NULL) {
|
---|
200 | spin_unlock_irq(&ice->reg_lock);
|
---|
201 | snd_ice1712_delta_cs8403_spdif_write(ice, val);
|
---|
202 | } else {
|
---|
203 | spin_unlock_irq(&ice->reg_lock);
|
---|
204 | }
|
---|
205 | return change;
|
---|
206 | }
|
---|
207 |
|
---|
208 | static void delta_spdif_stream_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol)
|
---|
209 | {
|
---|
210 | snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_stream_bits);
|
---|
211 | }
|
---|
212 |
|
---|
213 | static int delta_spdif_stream_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol)
|
---|
214 | {
|
---|
215 | unsigned int val;
|
---|
216 | int change;
|
---|
217 |
|
---|
218 | val = snd_cs8403_encode_spdif_bits(&ucontrol->value.iec958);
|
---|
219 | spin_lock_irq(&ice->reg_lock);
|
---|
220 | change = ice->spdif.cs8403_stream_bits != val;
|
---|
221 | ice->spdif.cs8403_stream_bits = val;
|
---|
222 | if (change && ice->playback_pro_substream != NULL) {
|
---|
223 | spin_unlock_irq(&ice->reg_lock);
|
---|
224 | snd_ice1712_delta_cs8403_spdif_write(ice, val);
|
---|
225 | } else {
|
---|
226 | spin_unlock_irq(&ice->reg_lock);
|
---|
227 | }
|
---|
228 | return change;
|
---|
229 | }
|
---|
230 |
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * AK4524 on Delta 44 and 66 to choose the chip mask
|
---|
234 | */
|
---|
235 | static int delta_ak4524_start(akm4xxx_t *ak, int chip)
|
---|
236 | {
|
---|
237 | snd_ice1712_save_gpio_status(ak->chip);
|
---|
238 | ak->cs_mask =
|
---|
239 | ak->cs_addr = chip == 0 ? ICE1712_DELTA_CODEC_CHIP_A :
|
---|
240 | ICE1712_DELTA_CODEC_CHIP_B;
|
---|
241 | return 0;
|
---|
242 | }
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * AK4524 on Delta1010LT to choose the chip address
|
---|
246 | */
|
---|
247 | static int delta1010lt_ak4524_start(akm4xxx_t *ak, int chip)
|
---|
248 | {
|
---|
249 | snd_ice1712_save_gpio_status(ak->chip);
|
---|
250 | ak->cs_mask = ICE1712_DELTA_1010LT_CS;
|
---|
251 | ak->cs_addr = chip << 4;
|
---|
252 | return 0;
|
---|
253 | }
|
---|
254 |
|
---|
255 | /*
|
---|
256 | * change the rate of AK4524 on Delta 44/66, AP, 1010LT
|
---|
257 | */
|
---|
258 | static void delta_ak4524_set_rate_val(akm4xxx_t *ak, unsigned int rate)
|
---|
259 | {
|
---|
260 | unsigned char tmp, tmp2;
|
---|
261 | ice1712_t *ice = ak->chip;
|
---|
262 |
|
---|
263 | if (rate == 0) /* no hint - S/PDIF input is master, simply return */
|
---|
264 | return;
|
---|
265 |
|
---|
266 | /* check before reset ak4524 to avoid unnecessary clicks */
|
---|
267 | down(&ice->gpio_mutex);
|
---|
268 | tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
|
---|
269 | up(&ice->gpio_mutex);
|
---|
270 | tmp2 = tmp;
|
---|
271 | tmp2 &= ~ICE1712_DELTA_DFS;
|
---|
272 | if (rate > 48000)
|
---|
273 | tmp2 |= ICE1712_DELTA_DFS;
|
---|
274 | if (tmp == tmp2)
|
---|
275 | return;
|
---|
276 |
|
---|
277 | /* do it again */
|
---|
278 | snd_ice1712_akm4xxx_reset(ak, 1);
|
---|
279 | down(&ice->gpio_mutex);
|
---|
280 | tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ~ICE1712_DELTA_DFS;
|
---|
281 | if (rate > 48000)
|
---|
282 | tmp |= ICE1712_DELTA_DFS;
|
---|
283 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
|
---|
284 | up(&ice->gpio_mutex);
|
---|
285 | snd_ice1712_akm4xxx_reset(ak, 0);
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | /*
|
---|
290 | * SPDIF ops for Delta 1010, Dio, 66
|
---|
291 | */
|
---|
292 |
|
---|
293 | /* open callback */
|
---|
294 | static void delta_open_spdif(ice1712_t *ice, snd_pcm_substream_t * substream)
|
---|
295 | {
|
---|
296 | ice->spdif.cs8403_stream_bits = ice->spdif.cs8403_bits;
|
---|
297 | }
|
---|
298 |
|
---|
299 | /* set up */
|
---|
300 | static void delta_setup_spdif(ice1712_t *ice, int rate)
|
---|
301 | {
|
---|
302 | unsigned long flags;
|
---|
303 | unsigned int tmp;
|
---|
304 | int change;
|
---|
305 |
|
---|
306 | spin_lock_irqsave(&ice->reg_lock, flags);
|
---|
307 | tmp = ice->spdif.cs8403_stream_bits;
|
---|
308 | if (tmp & 0x01) /* consumer */
|
---|
309 | tmp &= (tmp & 0x01) ? ~0x06 : ~0x18;
|
---|
310 | switch (rate) {
|
---|
311 | case 32000: tmp |= (tmp & 0x01) ? 0x04 : 0x00; break;
|
---|
312 | case 44100: tmp |= (tmp & 0x01) ? 0x00 : 0x10; break;
|
---|
313 | case 48000: tmp |= (tmp & 0x01) ? 0x02 : 0x08; break;
|
---|
314 | default: tmp |= (tmp & 0x01) ? 0x00 : 0x18; break;
|
---|
315 | }
|
---|
316 | change = ice->spdif.cs8403_stream_bits != tmp;
|
---|
317 | ice->spdif.cs8403_stream_bits = tmp;
|
---|
318 | spin_unlock_irqrestore(&ice->reg_lock, flags);
|
---|
319 | if (change)
|
---|
320 | snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &ice->spdif.stream_ctl->id);
|
---|
321 | snd_ice1712_delta_cs8403_spdif_write(ice, tmp);
|
---|
322 | }
|
---|
323 |
|
---|
324 |
|
---|
325 | /*
|
---|
326 | * initialize the chips on M-Audio cards
|
---|
327 | */
|
---|
328 |
|
---|
329 | static akm4xxx_t akm_audiophile __devinitdata = {
|
---|
330 | .type = SND_AK4528,
|
---|
331 | .num_adcs = 2,
|
---|
332 | .num_dacs = 2,
|
---|
333 | .caddr = 2,
|
---|
334 | .cif = 0,
|
---|
335 | .data_mask = ICE1712_DELTA_AP_DOUT,
|
---|
336 | .clk_mask = ICE1712_DELTA_AP_CCLK,
|
---|
337 | .cs_mask = ICE1712_DELTA_AP_CS_CODEC,
|
---|
338 | .cs_addr = ICE1712_DELTA_AP_CS_CODEC,
|
---|
339 | .cs_none = 0,
|
---|
340 | .add_flags = ICE1712_DELTA_AP_CS_DIGITAL,
|
---|
341 | .mask_flags = 0,
|
---|
342 | .ops = {
|
---|
343 | .set_rate_val = delta_ak4524_set_rate_val
|
---|
344 | }
|
---|
345 | };
|
---|
346 |
|
---|
347 | static akm4xxx_t akm_delta410 __devinitdata = {
|
---|
348 | .type = SND_AK4529,
|
---|
349 | .num_adcs = 2,
|
---|
350 | .num_dacs = 8,
|
---|
351 | .caddr = 0,
|
---|
352 | .cif = 0,
|
---|
353 | .data_mask = ICE1712_DELTA_AP_DOUT,
|
---|
354 | .clk_mask = ICE1712_DELTA_AP_CCLK,
|
---|
355 | .cs_mask = ICE1712_DELTA_AP_CS_CODEC,
|
---|
356 | .cs_addr = ICE1712_DELTA_AP_CS_CODEC,
|
---|
357 | .cs_none = 0,
|
---|
358 | .add_flags = ICE1712_DELTA_AP_CS_DIGITAL,
|
---|
359 | .mask_flags = 0,
|
---|
360 | .ops = {
|
---|
361 | .set_rate_val = delta_ak4524_set_rate_val
|
---|
362 | }
|
---|
363 | };
|
---|
364 |
|
---|
365 | static akm4xxx_t akm_delta1010lt __devinitdata = {
|
---|
366 | .type = SND_AK4524,
|
---|
367 | .num_adcs = 8,
|
---|
368 | .num_dacs = 8,
|
---|
369 | .caddr = 2,
|
---|
370 | .cif = 0, /* the default level of the CIF pin from AK4524 */
|
---|
371 | .data_mask = ICE1712_DELTA_1010LT_DOUT,
|
---|
372 | .clk_mask = ICE1712_DELTA_1010LT_CCLK,
|
---|
373 | .cs_mask = 0,
|
---|
374 | .cs_addr = 0, /* set later */
|
---|
375 | .cs_none = ICE1712_DELTA_1010LT_CS_NONE,
|
---|
376 | .add_flags = 0,
|
---|
377 | .mask_flags = 0,
|
---|
378 | .ops = {
|
---|
379 | .start = delta1010lt_ak4524_start,
|
---|
380 | .set_rate_val = delta_ak4524_set_rate_val
|
---|
381 | }
|
---|
382 | };
|
---|
383 |
|
---|
384 | static akm4xxx_t akm_delta44 __devinitdata = {
|
---|
385 | .type = SND_AK4524,
|
---|
386 | .num_adcs = 4,
|
---|
387 | .num_dacs = 4,
|
---|
388 | .caddr = 2,
|
---|
389 | .cif = 0, /* the default level of the CIF pin from AK4524 */
|
---|
390 | .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA,
|
---|
391 | .clk_mask = ICE1712_DELTA_CODEC_SERIAL_CLOCK,
|
---|
392 | .cs_mask = 0,
|
---|
393 | .cs_addr = 0, /* set later */
|
---|
394 | .cs_none = 0,
|
---|
395 | .add_flags = 0,
|
---|
396 | .mask_flags = 0,
|
---|
397 | .ops = {
|
---|
398 | .start = delta_ak4524_start,
|
---|
399 | .set_rate_val = delta_ak4524_set_rate_val
|
---|
400 | }
|
---|
401 | };
|
---|
402 |
|
---|
403 | static int __devinit snd_ice1712_delta_init(ice1712_t *ice)
|
---|
404 | {
|
---|
405 | int err;
|
---|
406 | akm4xxx_t *ak;
|
---|
407 |
|
---|
408 | /* determine I2C, DACs and ADCs */
|
---|
409 | switch (ice->eeprom.subvendor) {
|
---|
410 | case ICE1712_SUBDEVICE_AUDIOPHILE:
|
---|
411 | ice->num_total_dacs = 2;
|
---|
412 | break;
|
---|
413 | case ICE1712_SUBDEVICE_DELTA410:
|
---|
414 | ice->num_total_dacs = 8;
|
---|
415 | break;
|
---|
416 | case ICE1712_SUBDEVICE_DELTA44:
|
---|
417 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
418 | ice->num_total_dacs = ice->omni ? 8 : 4;
|
---|
419 | break;
|
---|
420 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
421 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
422 | ice->num_total_dacs = 8;
|
---|
423 | break;
|
---|
424 | }
|
---|
425 |
|
---|
426 | /* initialize spdif */
|
---|
427 | switch (ice->eeprom.subvendor) {
|
---|
428 | case ICE1712_SUBDEVICE_AUDIOPHILE:
|
---|
429 | case ICE1712_SUBDEVICE_DELTA410:
|
---|
430 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
431 | if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
|
---|
432 | snd_printk("unable to create I2C bus\n");
|
---|
433 | return err;
|
---|
434 | }
|
---|
435 | ice->i2c->private_data = ice;
|
---|
436 | ice->i2c->ops = &ap_cs8427_i2c_ops;
|
---|
437 | if ((err = snd_ice1712_init_cs8427(ice, CS8427_BASE_ADDR)) < 0)
|
---|
438 | return err;
|
---|
439 | break;
|
---|
440 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
441 | case ICE1712_SUBDEVICE_DELTADIO2496:
|
---|
442 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
443 | ice->spdif.ops.open = delta_open_spdif;
|
---|
444 | ice->spdif.ops.setup_rate = delta_setup_spdif;
|
---|
445 | ice->spdif.ops.default_get = delta_spdif_default_get;
|
---|
446 | ice->spdif.ops.default_put = delta_spdif_default_put;
|
---|
447 | ice->spdif.ops.stream_get = delta_spdif_stream_get;
|
---|
448 | ice->spdif.ops.stream_put = delta_spdif_stream_put;
|
---|
449 | /* Set spdif defaults */
|
---|
450 | snd_ice1712_delta_cs8403_spdif_write(ice, ice->spdif.cs8403_bits);
|
---|
451 | break;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /* no analog? */
|
---|
455 | switch (ice->eeprom.subvendor) {
|
---|
456 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
457 | case ICE1712_SUBDEVICE_DELTADIO2496:
|
---|
458 | return 0;
|
---|
459 | }
|
---|
460 |
|
---|
461 | /* second stage of initialization, analog parts and others */
|
---|
462 | ak = ice->akm = kmalloc(sizeof(akm4xxx_t), GFP_KERNEL);
|
---|
463 | if (! ak)
|
---|
464 | return -ENOMEM;
|
---|
465 | ice->akm_codecs = 1;
|
---|
466 |
|
---|
467 | switch (ice->eeprom.subvendor) {
|
---|
468 | case ICE1712_SUBDEVICE_AUDIOPHILE:
|
---|
469 | snd_ice1712_akm4xxx_init(ak, &akm_audiophile, ice);
|
---|
470 | break;
|
---|
471 | case ICE1712_SUBDEVICE_DELTA410:
|
---|
472 | snd_ice1712_akm4xxx_init(ak, &akm_delta410, ice);
|
---|
473 | break;
|
---|
474 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
475 | snd_ice1712_akm4xxx_init(ak, &akm_delta1010lt, ice);
|
---|
476 | break;
|
---|
477 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
478 | case ICE1712_SUBDEVICE_DELTA44:
|
---|
479 | snd_ice1712_akm4xxx_init(ak, &akm_delta44, ice);
|
---|
480 | break;
|
---|
481 | default:
|
---|
482 | snd_BUG();
|
---|
483 | return -EINVAL;
|
---|
484 | }
|
---|
485 |
|
---|
486 | return 0;
|
---|
487 | }
|
---|
488 |
|
---|
489 |
|
---|
490 | /*
|
---|
491 | * additional controls for M-Audio cards
|
---|
492 | */
|
---|
493 |
|
---|
494 | static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_select __devinitdata =
|
---|
495 | ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
|
---|
496 | static snd_kcontrol_new_t snd_ice1712_delta1010lt_wordclock_select __devinitdata =
|
---|
497 | ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 1, 0);
|
---|
498 | static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_status __devinitdata =
|
---|
499 | ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
|
---|
500 | static snd_kcontrol_new_t snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
|
---|
501 | ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
|
---|
502 | static snd_kcontrol_new_t snd_ice1712_delta_spdif_in_status __devinitdata =
|
---|
503 | ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
|
---|
504 |
|
---|
505 |
|
---|
506 | static int __devinit snd_ice1712_delta_add_controls(ice1712_t *ice)
|
---|
507 | {
|
---|
508 | int err;
|
---|
509 |
|
---|
510 | /* 1010 and dio specific controls */
|
---|
511 | switch (ice->eeprom.subvendor) {
|
---|
512 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
513 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010_wordclock_select, ice));
|
---|
514 | if (err < 0)
|
---|
515 | return err;
|
---|
516 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010_wordclock_status, ice));
|
---|
517 | if (err < 0)
|
---|
518 | return err;
|
---|
519 | break;
|
---|
520 | case ICE1712_SUBDEVICE_DELTADIO2496:
|
---|
521 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_deltadio2496_spdif_in_select, ice));
|
---|
522 | if (err < 0)
|
---|
523 | return err;
|
---|
524 | break;
|
---|
525 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
526 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010lt_wordclock_select, ice));
|
---|
527 | if (err < 0)
|
---|
528 | return err;
|
---|
529 | break;
|
---|
530 | }
|
---|
531 |
|
---|
532 | /* normal spdif controls */
|
---|
533 | switch (ice->eeprom.subvendor) {
|
---|
534 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
535 | case ICE1712_SUBDEVICE_DELTADIO2496:
|
---|
536 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
537 | case ICE1712_SUBDEVICE_AUDIOPHILE:
|
---|
538 | case ICE1712_SUBDEVICE_DELTA410:
|
---|
539 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
540 | err = snd_ice1712_spdif_build_controls(ice);
|
---|
541 | if (err < 0)
|
---|
542 | return err;
|
---|
543 | break;
|
---|
544 | }
|
---|
545 |
|
---|
546 | /* spdif status in */
|
---|
547 | switch (ice->eeprom.subvendor) {
|
---|
548 | case ICE1712_SUBDEVICE_DELTA1010:
|
---|
549 | case ICE1712_SUBDEVICE_DELTADIO2496:
|
---|
550 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
551 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta_spdif_in_status, ice));
|
---|
552 | if (err < 0)
|
---|
553 | return err;
|
---|
554 | break;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /* ak4524 controls */
|
---|
558 | switch (ice->eeprom.subvendor) {
|
---|
559 | case ICE1712_SUBDEVICE_DELTA1010LT:
|
---|
560 | case ICE1712_SUBDEVICE_AUDIOPHILE:
|
---|
561 | case ICE1712_SUBDEVICE_DELTA410:
|
---|
562 | case ICE1712_SUBDEVICE_DELTA44:
|
---|
563 | case ICE1712_SUBDEVICE_DELTA66:
|
---|
564 | err = snd_ice1712_akm4xxx_build_controls(ice);
|
---|
565 | if (err < 0)
|
---|
566 | return err;
|
---|
567 | break;
|
---|
568 | }
|
---|
569 | return 0;
|
---|
570 | }
|
---|
571 |
|
---|
572 |
|
---|
573 | /* entry point */
|
---|
574 | struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
|
---|
575 | {
|
---|
576 | ICE1712_SUBDEVICE_DELTA1010,
|
---|
577 | "M Audio Delta 1010",
|
---|
578 | snd_ice1712_delta_init,
|
---|
579 | snd_ice1712_delta_add_controls,
|
---|
580 | },
|
---|
581 | {
|
---|
582 | ICE1712_SUBDEVICE_DELTADIO2496,
|
---|
583 | "M Audio Delta DiO 2496",
|
---|
584 | snd_ice1712_delta_init,
|
---|
585 | snd_ice1712_delta_add_controls,
|
---|
586 | 1, /* NO MPU */
|
---|
587 | },
|
---|
588 | {
|
---|
589 | ICE1712_SUBDEVICE_DELTA66,
|
---|
590 | "M Audio Delta 66",
|
---|
591 | snd_ice1712_delta_init,
|
---|
592 | snd_ice1712_delta_add_controls,
|
---|
593 | 1, /* NO MPU */
|
---|
594 | },
|
---|
595 | {
|
---|
596 | ICE1712_SUBDEVICE_DELTA44,
|
---|
597 | "M Audio Delta 44",
|
---|
598 | snd_ice1712_delta_init,
|
---|
599 | snd_ice1712_delta_add_controls,
|
---|
600 | 1, /* NO MPU */
|
---|
601 | },
|
---|
602 | {
|
---|
603 | ICE1712_SUBDEVICE_AUDIOPHILE,
|
---|
604 | "M Audio Audiophile 24/96",
|
---|
605 | snd_ice1712_delta_init,
|
---|
606 | snd_ice1712_delta_add_controls,
|
---|
607 | },
|
---|
608 | {
|
---|
609 | ICE1712_SUBDEVICE_DELTA410,
|
---|
610 | "M Audio Delta 410",
|
---|
611 | snd_ice1712_delta_init,
|
---|
612 | snd_ice1712_delta_add_controls,
|
---|
613 | },
|
---|
614 | {
|
---|
615 | ICE1712_SUBDEVICE_DELTA1010LT,
|
---|
616 | "M Audio Delta 1010LT",
|
---|
617 | snd_ice1712_delta_init,
|
---|
618 | snd_ice1712_delta_add_controls,
|
---|
619 | },
|
---|
620 | { } /* terminator */
|
---|
621 | };
|
---|