2 * ALSA driver for VT1724 ICEnsemble ICE1724 / VIA VT1724 (Envy24HT)
3 * VIA VT1720 (Envy24PT)
5 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
6 * 2002 James Stafford <jstafford@ampltd.com>
7 * 2003 Takashi Iwai <tiwai@suse.de>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/delay.h>
27 #include <linux/interrupt.h>
28 #include <linux/init.h>
29 #include <linux/pci.h>
30 #include <linux/slab.h>
31 #include <linux/moduleparam.h>
32 #include <linux/mutex.h>
33 #include <sound/core.h>
34 #include <sound/info.h>
35 #include <sound/mpu401.h>
36 #include <sound/initval.h>
38 #include <sound/asoundef.h>
43 /* lowlevel routines */
47 #include "vt1720_mobo.h"
49 #include "prodigy192.h"
50 #include "prodigy_hifi.h"
56 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
57 MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)");
58 MODULE_LICENSE("GPL");
59 MODULE_SUPPORTED_DEVICE("{"
61 AMP_AUDIO2000_DEVICE_DESC
63 VT1720_MOBO_DEVICE_DESC
65 PRODIGY192_DEVICE_DESC
66 PRODIGY_HIFI_DEVICE_DESC
73 "{ICEnsemble,Generic ICE1724},"
74 "{ICEnsemble,Generic Envy24HT}"
75 "{ICEnsemble,Generic Envy24PT}}");
77 static int index
[SNDRV_CARDS
] = SNDRV_DEFAULT_IDX
; /* Index 0-MAX */
78 static char *id
[SNDRV_CARDS
] = SNDRV_DEFAULT_STR
; /* ID for this card */
79 static int enable
[SNDRV_CARDS
] = SNDRV_DEFAULT_ENABLE_PNP
; /* Enable this card */
80 static char *model
[SNDRV_CARDS
];
82 module_param_array(index
, int, NULL
, 0444);
83 MODULE_PARM_DESC(index
, "Index value for ICE1724 soundcard.");
84 module_param_array(id
, charp
, NULL
, 0444);
85 MODULE_PARM_DESC(id
, "ID string for ICE1724 soundcard.");
86 module_param_array(enable
, bool, NULL
, 0444);
87 MODULE_PARM_DESC(enable
, "Enable ICE1724 soundcard.");
88 module_param_array(model
, charp
, NULL
, 0444);
89 MODULE_PARM_DESC(model
, "Use the given board model.");
92 /* Both VT1720 and VT1724 have the same PCI IDs */
93 static const struct pci_device_id snd_vt1724_ids
[] = {
94 { PCI_VENDOR_ID_ICE
, PCI_DEVICE_ID_VT1724
, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
98 MODULE_DEVICE_TABLE(pci
, snd_vt1724_ids
);
101 static int PRO_RATE_LOCKED
;
102 static int PRO_RATE_RESET
= 1;
103 static unsigned int PRO_RATE_DEFAULT
= 44100;
110 * default rates, default clock routines
113 /* check whether the clock mode is spdif-in */
114 static inline int stdclock_is_spdif_master(struct snd_ice1712
*ice
)
116 return (inb(ICEMT1724(ice
, RATE
)) & VT1724_SPDIF_MASTER
) ? 1 : 0;
119 static inline int is_pro_rate_locked(struct snd_ice1712
*ice
)
121 return ice
->is_spdif_master(ice
) || PRO_RATE_LOCKED
;
128 static unsigned char snd_vt1724_ac97_ready(struct snd_ice1712
*ice
)
130 unsigned char old_cmd
;
132 for (tm
= 0; tm
< 0x10000; tm
++) {
133 old_cmd
= inb(ICEMT1724(ice
, AC97_CMD
));
134 if (old_cmd
& (VT1724_AC97_WRITE
| VT1724_AC97_READ
))
136 if (!(old_cmd
& VT1724_AC97_READY
))
140 snd_printd(KERN_ERR
"snd_vt1724_ac97_ready: timeout\n");
144 static int snd_vt1724_ac97_wait_bit(struct snd_ice1712
*ice
, unsigned char bit
)
147 for (tm
= 0; tm
< 0x10000; tm
++)
148 if ((inb(ICEMT1724(ice
, AC97_CMD
)) & bit
) == 0)
150 snd_printd(KERN_ERR
"snd_vt1724_ac97_wait_bit: timeout\n");
154 static void snd_vt1724_ac97_write(struct snd_ac97
*ac97
,
158 struct snd_ice1712
*ice
= ac97
->private_data
;
159 unsigned char old_cmd
;
161 old_cmd
= snd_vt1724_ac97_ready(ice
);
162 old_cmd
&= ~VT1724_AC97_ID_MASK
;
163 old_cmd
|= ac97
->num
;
164 outb(reg
, ICEMT1724(ice
, AC97_INDEX
));
165 outw(val
, ICEMT1724(ice
, AC97_DATA
));
166 outb(old_cmd
| VT1724_AC97_WRITE
, ICEMT1724(ice
, AC97_CMD
));
167 snd_vt1724_ac97_wait_bit(ice
, VT1724_AC97_WRITE
);
170 static unsigned short snd_vt1724_ac97_read(struct snd_ac97
*ac97
, unsigned short reg
)
172 struct snd_ice1712
*ice
= ac97
->private_data
;
173 unsigned char old_cmd
;
175 old_cmd
= snd_vt1724_ac97_ready(ice
);
176 old_cmd
&= ~VT1724_AC97_ID_MASK
;
177 old_cmd
|= ac97
->num
;
178 outb(reg
, ICEMT1724(ice
, AC97_INDEX
));
179 outb(old_cmd
| VT1724_AC97_READ
, ICEMT1724(ice
, AC97_CMD
));
180 if (snd_vt1724_ac97_wait_bit(ice
, VT1724_AC97_READ
) < 0)
182 return inw(ICEMT1724(ice
, AC97_DATA
));
190 /* set gpio direction 0 = read, 1 = write */
191 static void snd_vt1724_set_gpio_dir(struct snd_ice1712
*ice
, unsigned int data
)
193 outl(data
, ICEREG1724(ice
, GPIO_DIRECTION
));
194 inw(ICEREG1724(ice
, GPIO_DIRECTION
)); /* dummy read for pci-posting */
197 /* set the gpio mask (0 = writable) */
198 static void snd_vt1724_set_gpio_mask(struct snd_ice1712
*ice
, unsigned int data
)
200 outw(data
, ICEREG1724(ice
, GPIO_WRITE_MASK
));
201 if (! ice
->vt1720
) /* VT1720 supports only 16 GPIO bits */
202 outb((data
>> 16) & 0xff, ICEREG1724(ice
, GPIO_WRITE_MASK_22
));
203 inw(ICEREG1724(ice
, GPIO_WRITE_MASK
)); /* dummy read for pci-posting */
206 static void snd_vt1724_set_gpio_data(struct snd_ice1712
*ice
, unsigned int data
)
208 outw(data
, ICEREG1724(ice
, GPIO_DATA
));
210 outb(data
>> 16, ICEREG1724(ice
, GPIO_DATA_22
));
211 inw(ICEREG1724(ice
, GPIO_DATA
)); /* dummy read for pci-posting */
214 static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712
*ice
)
218 data
= (unsigned int)inb(ICEREG1724(ice
, GPIO_DATA_22
));
221 data
= (data
<< 16) | inw(ICEREG1724(ice
, GPIO_DATA
));
228 static unsigned char snd_vt1724_mpu401_read(struct snd_mpu401
*mpu
,
231 /* fix status bits to the standard position */
232 /* only RX_EMPTY and TX_FULL are checked */
233 if (addr
== MPU401C(mpu
))
234 return (inb(addr
) & 0x0c) << 4;
239 static void snd_vt1724_mpu401_write(struct snd_mpu401
*mpu
,
240 unsigned char data
, unsigned long addr
)
242 if (addr
== MPU401C(mpu
)) {
243 if (data
== MPU401_ENTER_UART
)
255 static irqreturn_t
snd_vt1724_interrupt(int irq
, void *dev_id
)
257 struct snd_ice1712
*ice
= dev_id
;
258 unsigned char status
;
259 unsigned char status_mask
=
260 VT1724_IRQ_MPU_RX
| VT1724_IRQ_MPU_TX
| VT1724_IRQ_MTPCM
;
262 #ifdef CONFIG_SND_DEBUG
267 status
= inb(ICEREG1724(ice
, IRQSTAT
));
268 status
&= status_mask
;
271 #ifdef CONFIG_SND_DEBUG
272 if (++timeout
> 10) {
274 "ice1724: Too long irq loop, status = 0x%x\n",
280 if (status
& VT1724_IRQ_MPU_TX
) {
282 snd_mpu401_uart_interrupt_tx(irq
,
283 ice
->rmidi
[0]->private_data
);
284 else /* disable TX to be sure */
285 outb(inb(ICEREG1724(ice
, IRQMASK
)) |
287 ICEREG1724(ice
, IRQMASK
));
288 /* Due to mysterical reasons, MPU_TX is always
289 * generated (and can't be cleared) when a PCM
290 * playback is going. So let's ignore at the
293 status_mask
&= ~VT1724_IRQ_MPU_TX
;
295 if (status
& VT1724_IRQ_MPU_RX
) {
297 snd_mpu401_uart_interrupt(irq
,
298 ice
->rmidi
[0]->private_data
);
299 else /* disable RX to be sure */
300 outb(inb(ICEREG1724(ice
, IRQMASK
)) |
302 ICEREG1724(ice
, IRQMASK
));
305 outb(status
, ICEREG1724(ice
, IRQSTAT
));
306 if (status
& VT1724_IRQ_MTPCM
) {
309 * PCM assignment are:
310 * Playback DMA0 (M/C) = playback_pro_substream
311 * Playback DMA1 = playback_con_substream_ds[0]
312 * Playback DMA2 = playback_con_substream_ds[1]
313 * Playback DMA3 = playback_con_substream_ds[2]
314 * Playback DMA4 (SPDIF) = playback_con_substream
315 * Record DMA0 = capture_pro_substream
316 * Record DMA1 = capture_con_substream
318 unsigned char mtstat
= inb(ICEMT1724(ice
, IRQ
));
319 if (mtstat
& VT1724_MULTI_PDMA0
) {
320 if (ice
->playback_pro_substream
)
321 snd_pcm_period_elapsed(ice
->playback_pro_substream
);
323 if (mtstat
& VT1724_MULTI_RDMA0
) {
324 if (ice
->capture_pro_substream
)
325 snd_pcm_period_elapsed(ice
->capture_pro_substream
);
327 if (mtstat
& VT1724_MULTI_PDMA1
) {
328 if (ice
->playback_con_substream_ds
[0])
329 snd_pcm_period_elapsed(ice
->playback_con_substream_ds
[0]);
331 if (mtstat
& VT1724_MULTI_PDMA2
) {
332 if (ice
->playback_con_substream_ds
[1])
333 snd_pcm_period_elapsed(ice
->playback_con_substream_ds
[1]);
335 if (mtstat
& VT1724_MULTI_PDMA3
) {
336 if (ice
->playback_con_substream_ds
[2])
337 snd_pcm_period_elapsed(ice
->playback_con_substream_ds
[2]);
339 if (mtstat
& VT1724_MULTI_PDMA4
) {
340 if (ice
->playback_con_substream
)
341 snd_pcm_period_elapsed(ice
->playback_con_substream
);
343 if (mtstat
& VT1724_MULTI_RDMA1
) {
344 if (ice
->capture_con_substream
)
345 snd_pcm_period_elapsed(ice
->capture_con_substream
);
347 /* ack anyway to avoid freeze */
348 outb(mtstat
, ICEMT1724(ice
, IRQ
));
349 /* ought to really handle this properly */
350 if (mtstat
& VT1724_MULTI_FIFO_ERR
) {
351 unsigned char fstat
= inb(ICEMT1724(ice
, DMA_FIFO_ERR
));
352 outb(fstat
, ICEMT1724(ice
, DMA_FIFO_ERR
));
353 outb(VT1724_MULTI_FIFO_ERR
| inb(ICEMT1724(ice
, DMA_INT_MASK
)), ICEMT1724(ice
, DMA_INT_MASK
));
354 /* If I don't do this, I get machine lockup due to continual interrupts */
359 return IRQ_RETVAL(handled
);
363 * PCM code - professional part (multitrack)
366 static unsigned int rates
[] = {
367 8000, 9600, 11025, 12000, 16000, 22050, 24000,
368 32000, 44100, 48000, 64000, 88200, 96000,
372 static struct snd_pcm_hw_constraint_list hw_constraints_rates_96
= {
373 .count
= ARRAY_SIZE(rates
) - 2, /* up to 96000 */
378 static struct snd_pcm_hw_constraint_list hw_constraints_rates_48
= {
379 .count
= ARRAY_SIZE(rates
) - 5, /* up to 48000 */
384 static struct snd_pcm_hw_constraint_list hw_constraints_rates_192
= {
385 .count
= ARRAY_SIZE(rates
),
390 struct vt1724_pcm_reg
{
391 unsigned int addr
; /* ADDR register offset */
392 unsigned int size
; /* SIZE register offset */
393 unsigned int count
; /* COUNT register offset */
394 unsigned int start
; /* start & pause bit */
397 static int snd_vt1724_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
)
399 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
402 struct snd_pcm_substream
*s
;
405 snd_pcm_group_for_each_entry(s
, substream
) {
406 if (snd_pcm_substream_chip(s
) == ice
) {
407 const struct vt1724_pcm_reg
*reg
;
408 reg
= s
->runtime
->private_data
;
410 snd_pcm_trigger_done(s
, substream
);
415 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
416 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
417 spin_lock(&ice
->reg_lock
);
418 old
= inb(ICEMT1724(ice
, DMA_PAUSE
));
419 if (cmd
== SNDRV_PCM_TRIGGER_PAUSE_PUSH
)
423 outb(old
, ICEMT1724(ice
, DMA_PAUSE
));
424 spin_unlock(&ice
->reg_lock
);
427 case SNDRV_PCM_TRIGGER_START
:
428 case SNDRV_PCM_TRIGGER_STOP
:
429 spin_lock(&ice
->reg_lock
);
430 old
= inb(ICEMT1724(ice
, DMA_CONTROL
));
431 if (cmd
== SNDRV_PCM_TRIGGER_START
)
435 outb(old
, ICEMT1724(ice
, DMA_CONTROL
));
436 spin_unlock(&ice
->reg_lock
);
448 #define DMA_STARTS (VT1724_RDMA0_START|VT1724_PDMA0_START|VT1724_RDMA1_START|\
449 VT1724_PDMA1_START|VT1724_PDMA2_START|VT1724_PDMA3_START|VT1724_PDMA4_START)
450 #define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\
451 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE)
453 static const unsigned int stdclock_rate_list
[16] = {
454 48000, 24000, 12000, 9600, 32000, 16000, 8000, 96000, 44100,
455 22050, 11025, 88200, 176400, 0, 192000, 64000
458 static unsigned int stdclock_get_rate(struct snd_ice1712
*ice
)
461 rate
= stdclock_rate_list
[inb(ICEMT1724(ice
, RATE
)) & 15];
465 static void stdclock_set_rate(struct snd_ice1712
*ice
, unsigned int rate
)
468 for (i
= 0; i
< ARRAY_SIZE(stdclock_rate_list
); i
++) {
469 if (stdclock_rate_list
[i
] == rate
) {
470 outb(i
, ICEMT1724(ice
, RATE
));
476 static unsigned char stdclock_set_mclk(struct snd_ice1712
*ice
,
479 unsigned char val
, old
;
481 if (ice
->eeprom
.data
[ICE_EEP2_ACLINK
] & VT1724_CFG_PRO_I2S
) {
482 val
= old
= inb(ICEMT1724(ice
, I2S_FORMAT
));
484 val
|= VT1724_MT_I2S_MCLK_128X
; /* 128x MCLK */
486 val
&= ~VT1724_MT_I2S_MCLK_128X
; /* 256x MCLK */
488 outb(val
, ICEMT1724(ice
, I2S_FORMAT
));
489 /* master clock changed */
493 /* no change in master clock */
497 static void snd_vt1724_set_pro_rate(struct snd_ice1712
*ice
, unsigned int rate
,
501 unsigned char mclk_change
;
502 unsigned int i
, old_rate
;
504 if (rate
> ice
->hw_rates
->list
[ice
->hw_rates
->count
- 1])
506 spin_lock_irqsave(&ice
->reg_lock
, flags
);
507 if ((inb(ICEMT1724(ice
, DMA_CONTROL
)) & DMA_STARTS
) ||
508 (inb(ICEMT1724(ice
, DMA_PAUSE
)) & DMA_PAUSES
)) {
509 /* running? we cannot change the rate now... */
510 spin_unlock_irqrestore(&ice
->reg_lock
, flags
);
513 if (!force
&& is_pro_rate_locked(ice
)) {
514 spin_unlock_irqrestore(&ice
->reg_lock
, flags
);
518 old_rate
= ice
->get_rate(ice
);
519 if (force
|| (old_rate
!= rate
))
520 ice
->set_rate(ice
, rate
);
521 else if (rate
== ice
->cur_rate
) {
522 spin_unlock_irqrestore(&ice
->reg_lock
, flags
);
526 ice
->cur_rate
= rate
;
528 /* setting master clock */
529 mclk_change
= ice
->set_mclk(ice
, rate
);
531 spin_unlock_irqrestore(&ice
->reg_lock
, flags
);
533 if (mclk_change
&& ice
->gpio
.i2s_mclk_changed
)
534 ice
->gpio
.i2s_mclk_changed(ice
);
535 if (ice
->gpio
.set_pro_rate
)
536 ice
->gpio
.set_pro_rate(ice
, rate
);
539 for (i
= 0; i
< ice
->akm_codecs
; i
++) {
540 if (ice
->akm
[i
].ops
.set_rate_val
)
541 ice
->akm
[i
].ops
.set_rate_val(&ice
->akm
[i
], rate
);
543 if (ice
->spdif
.ops
.setup_rate
)
544 ice
->spdif
.ops
.setup_rate(ice
, rate
);
547 static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream
*substream
,
548 struct snd_pcm_hw_params
*hw_params
)
550 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
553 chs
= params_channels(hw_params
);
554 mutex_lock(&ice
->open_mutex
);
555 /* mark surround channels */
556 if (substream
== ice
->playback_pro_substream
) {
557 /* PDMA0 can be multi-channel up to 8 */
559 for (i
= 0; i
< chs
; i
++) {
560 if (ice
->pcm_reserved
[i
] &&
561 ice
->pcm_reserved
[i
] != substream
) {
562 mutex_unlock(&ice
->open_mutex
);
565 ice
->pcm_reserved
[i
] = substream
;
568 if (ice
->pcm_reserved
[i
] == substream
)
569 ice
->pcm_reserved
[i
] = NULL
;
572 for (i
= 0; i
< 3; i
++) {
573 /* check individual playback stream */
574 if (ice
->playback_con_substream_ds
[i
] == substream
) {
575 if (ice
->pcm_reserved
[i
] &&
576 ice
->pcm_reserved
[i
] != substream
) {
577 mutex_unlock(&ice
->open_mutex
);
580 ice
->pcm_reserved
[i
] = substream
;
585 mutex_unlock(&ice
->open_mutex
);
586 snd_vt1724_set_pro_rate(ice
, params_rate(hw_params
), 0);
587 return snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
));
590 static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream
*substream
)
592 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
595 mutex_lock(&ice
->open_mutex
);
596 /* unmark surround channels */
597 for (i
= 0; i
< 3; i
++)
598 if (ice
->pcm_reserved
[i
] == substream
)
599 ice
->pcm_reserved
[i
] = NULL
;
600 mutex_unlock(&ice
->open_mutex
);
601 return snd_pcm_lib_free_pages(substream
);
604 static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream
*substream
)
606 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
610 spin_lock_irq(&ice
->reg_lock
);
611 val
= (8 - substream
->runtime
->channels
) >> 1;
612 outb(val
, ICEMT1724(ice
, BURST
));
614 outl(substream
->runtime
->dma_addr
, ICEMT1724(ice
, PLAYBACK_ADDR
));
616 size
= (snd_pcm_lib_buffer_bytes(substream
) >> 2) - 1;
617 // outl(size, ICEMT1724(ice, PLAYBACK_SIZE));
618 outw(size
, ICEMT1724(ice
, PLAYBACK_SIZE
));
619 outb(size
>> 16, ICEMT1724(ice
, PLAYBACK_SIZE
) + 2);
620 size
= (snd_pcm_lib_period_bytes(substream
) >> 2) - 1;
621 // outl(size, ICEMT1724(ice, PLAYBACK_COUNT));
622 outw(size
, ICEMT1724(ice
, PLAYBACK_COUNT
));
623 outb(size
>> 16, ICEMT1724(ice
, PLAYBACK_COUNT
) + 2);
625 spin_unlock_irq(&ice
->reg_lock
);
627 // printk("pro prepare: ch = %d, addr = 0x%x, buffer = 0x%x, period = 0x%x\n", substream->runtime->channels, (unsigned int)substream->runtime->dma_addr, snd_pcm_lib_buffer_bytes(substream), snd_pcm_lib_period_bytes(substream));
631 static snd_pcm_uframes_t
snd_vt1724_playback_pro_pointer(struct snd_pcm_substream
*substream
)
633 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
636 if (!(inl(ICEMT1724(ice
, DMA_CONTROL
)) & VT1724_PDMA0_START
))
638 #if 0 /* read PLAYBACK_ADDR */
639 ptr
= inl(ICEMT1724(ice
, PLAYBACK_ADDR
));
640 if (ptr
< substream
->runtime
->dma_addr
) {
641 snd_printd("ice1724: invalid negative ptr\n");
644 ptr
-= substream
->runtime
->dma_addr
;
645 ptr
= bytes_to_frames(substream
->runtime
, ptr
);
646 if (ptr
>= substream
->runtime
->buffer_size
) {
647 snd_printd("ice1724: invalid ptr %d (size=%d)\n",
648 (int)ptr
, (int)substream
->runtime
->period_size
);
651 #else /* read PLAYBACK_SIZE */
652 ptr
= inl(ICEMT1724(ice
, PLAYBACK_SIZE
)) & 0xffffff;
653 ptr
= (ptr
+ 1) << 2;
654 ptr
= bytes_to_frames(substream
->runtime
, ptr
);
657 else if (ptr
<= substream
->runtime
->buffer_size
)
658 ptr
= substream
->runtime
->buffer_size
- ptr
;
660 snd_printd("ice1724: invalid ptr %d (size=%d)\n",
661 (int)ptr
, (int)substream
->runtime
->buffer_size
);
668 static int snd_vt1724_pcm_prepare(struct snd_pcm_substream
*substream
)
670 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
671 const struct vt1724_pcm_reg
*reg
= substream
->runtime
->private_data
;
673 spin_lock_irq(&ice
->reg_lock
);
674 outl(substream
->runtime
->dma_addr
, ice
->profi_port
+ reg
->addr
);
675 outw((snd_pcm_lib_buffer_bytes(substream
) >> 2) - 1,
676 ice
->profi_port
+ reg
->size
);
677 outw((snd_pcm_lib_period_bytes(substream
) >> 2) - 1,
678 ice
->profi_port
+ reg
->count
);
679 spin_unlock_irq(&ice
->reg_lock
);
683 static snd_pcm_uframes_t
snd_vt1724_pcm_pointer(struct snd_pcm_substream
*substream
)
685 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
686 const struct vt1724_pcm_reg
*reg
= substream
->runtime
->private_data
;
689 if (!(inl(ICEMT1724(ice
, DMA_CONTROL
)) & reg
->start
))
691 #if 0 /* use ADDR register */
692 ptr
= inl(ice
->profi_port
+ reg
->addr
);
693 ptr
-= substream
->runtime
->dma_addr
;
694 return bytes_to_frames(substream
->runtime
, ptr
);
695 #else /* use SIZE register */
696 ptr
= inw(ice
->profi_port
+ reg
->size
);
697 ptr
= (ptr
+ 1) << 2;
698 ptr
= bytes_to_frames(substream
->runtime
, ptr
);
701 else if (ptr
<= substream
->runtime
->buffer_size
)
702 ptr
= substream
->runtime
->buffer_size
- ptr
;
704 snd_printd("ice1724: invalid ptr %d (size=%d)\n",
705 (int)ptr
, (int)substream
->runtime
->buffer_size
);
712 static const struct vt1724_pcm_reg vt1724_playback_pro_reg
= {
713 .addr
= VT1724_MT_PLAYBACK_ADDR
,
714 .size
= VT1724_MT_PLAYBACK_SIZE
,
715 .count
= VT1724_MT_PLAYBACK_COUNT
,
716 .start
= VT1724_PDMA0_START
,
719 static const struct vt1724_pcm_reg vt1724_capture_pro_reg
= {
720 .addr
= VT1724_MT_CAPTURE_ADDR
,
721 .size
= VT1724_MT_CAPTURE_SIZE
,
722 .count
= VT1724_MT_CAPTURE_COUNT
,
723 .start
= VT1724_RDMA0_START
,
726 static const struct snd_pcm_hardware snd_vt1724_playback_pro
=
728 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
729 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
730 SNDRV_PCM_INFO_MMAP_VALID
|
731 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_SYNC_START
),
732 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
733 .rates
= SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_8000_192000
,
738 .buffer_bytes_max
= (1UL << 21), /* 19bits dword */
739 .period_bytes_min
= 8 * 4 * 2, /* FIXME: constraints needed */
740 .period_bytes_max
= (1UL << 21),
745 static const struct snd_pcm_hardware snd_vt1724_spdif
=
747 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
748 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
749 SNDRV_PCM_INFO_MMAP_VALID
|
750 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_SYNC_START
),
751 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
752 .rates
= (SNDRV_PCM_RATE_32000
|SNDRV_PCM_RATE_44100
|
753 SNDRV_PCM_RATE_48000
|SNDRV_PCM_RATE_88200
|
754 SNDRV_PCM_RATE_96000
|SNDRV_PCM_RATE_176400
|
755 SNDRV_PCM_RATE_192000
),
760 .buffer_bytes_max
= (1UL << 18), /* 16bits dword */
761 .period_bytes_min
= 2 * 4 * 2,
762 .period_bytes_max
= (1UL << 18),
767 static const struct snd_pcm_hardware snd_vt1724_2ch_stereo
=
769 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
770 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
771 SNDRV_PCM_INFO_MMAP_VALID
|
772 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_SYNC_START
),
773 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
774 .rates
= SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_8000_192000
,
779 .buffer_bytes_max
= (1UL << 18), /* 16bits dword */
780 .period_bytes_min
= 2 * 4 * 2,
781 .period_bytes_max
= (1UL << 18),
787 * set rate constraints
789 static void set_std_hw_rates(struct snd_ice1712
*ice
)
791 if (ice
->eeprom
.data
[ICE_EEP2_ACLINK
] & VT1724_CFG_PRO_I2S
) {
793 /* VT1720 doesn't support more than 96kHz */
794 if ((ice
->eeprom
.data
[ICE_EEP2_I2S
] & 0x08) && !ice
->vt1720
)
795 ice
->hw_rates
= &hw_constraints_rates_192
;
797 ice
->hw_rates
= &hw_constraints_rates_96
;
800 ice
->hw_rates
= &hw_constraints_rates_48
;
804 static int set_rate_constraints(struct snd_ice1712
*ice
,
805 struct snd_pcm_substream
*substream
)
807 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
809 runtime
->hw
.rate_min
= ice
->hw_rates
->list
[0];
810 runtime
->hw
.rate_max
= ice
->hw_rates
->list
[ice
->hw_rates
->count
- 1];
811 runtime
->hw
.rates
= SNDRV_PCM_RATE_KNOT
;
812 return snd_pcm_hw_constraint_list(runtime
, 0,
813 SNDRV_PCM_HW_PARAM_RATE
,
817 /* multi-channel playback needs alignment 8x32bit regardless of the channels
820 #define VT1724_BUFFER_ALIGN 0x20
822 static int snd_vt1724_playback_pro_open(struct snd_pcm_substream
*substream
)
824 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
825 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
828 runtime
->private_data
= (void *)&vt1724_playback_pro_reg
;
829 ice
->playback_pro_substream
= substream
;
830 runtime
->hw
= snd_vt1724_playback_pro
;
831 snd_pcm_set_sync(substream
);
832 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
833 set_rate_constraints(ice
, substream
);
834 mutex_lock(&ice
->open_mutex
);
835 /* calculate the currently available channels */
836 for (chs
= 0; chs
< 3; chs
++) {
837 if (ice
->pcm_reserved
[chs
])
841 runtime
->hw
.channels_max
= chs
;
842 if (chs
> 2) /* channels must be even */
843 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_CHANNELS
, 2);
844 mutex_unlock(&ice
->open_mutex
);
845 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
846 VT1724_BUFFER_ALIGN
);
847 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
848 VT1724_BUFFER_ALIGN
);
852 static int snd_vt1724_capture_pro_open(struct snd_pcm_substream
*substream
)
854 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
855 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
857 runtime
->private_data
= (void *)&vt1724_capture_pro_reg
;
858 ice
->capture_pro_substream
= substream
;
859 runtime
->hw
= snd_vt1724_2ch_stereo
;
860 snd_pcm_set_sync(substream
);
861 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
862 set_rate_constraints(ice
, substream
);
863 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
864 VT1724_BUFFER_ALIGN
);
865 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
866 VT1724_BUFFER_ALIGN
);
870 static int snd_vt1724_playback_pro_close(struct snd_pcm_substream
*substream
)
872 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
875 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 0);
876 ice
->playback_pro_substream
= NULL
;
881 static int snd_vt1724_capture_pro_close(struct snd_pcm_substream
*substream
)
883 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
886 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 0);
887 ice
->capture_pro_substream
= NULL
;
891 static struct snd_pcm_ops snd_vt1724_playback_pro_ops
= {
892 .open
= snd_vt1724_playback_pro_open
,
893 .close
= snd_vt1724_playback_pro_close
,
894 .ioctl
= snd_pcm_lib_ioctl
,
895 .hw_params
= snd_vt1724_pcm_hw_params
,
896 .hw_free
= snd_vt1724_pcm_hw_free
,
897 .prepare
= snd_vt1724_playback_pro_prepare
,
898 .trigger
= snd_vt1724_pcm_trigger
,
899 .pointer
= snd_vt1724_playback_pro_pointer
,
902 static struct snd_pcm_ops snd_vt1724_capture_pro_ops
= {
903 .open
= snd_vt1724_capture_pro_open
,
904 .close
= snd_vt1724_capture_pro_close
,
905 .ioctl
= snd_pcm_lib_ioctl
,
906 .hw_params
= snd_vt1724_pcm_hw_params
,
907 .hw_free
= snd_vt1724_pcm_hw_free
,
908 .prepare
= snd_vt1724_pcm_prepare
,
909 .trigger
= snd_vt1724_pcm_trigger
,
910 .pointer
= snd_vt1724_pcm_pointer
,
913 static int __devinit
snd_vt1724_pcm_profi(struct snd_ice1712
* ice
, int device
)
918 err
= snd_pcm_new(ice
->card
, "ICE1724", device
, 1, 1, &pcm
);
922 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_vt1724_playback_pro_ops
);
923 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_vt1724_capture_pro_ops
);
925 pcm
->private_data
= ice
;
927 strcpy(pcm
->name
, "ICE1724");
929 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
,
930 snd_dma_pci_data(ice
->pci
),
943 static const struct vt1724_pcm_reg vt1724_playback_spdif_reg
= {
944 .addr
= VT1724_MT_PDMA4_ADDR
,
945 .size
= VT1724_MT_PDMA4_SIZE
,
946 .count
= VT1724_MT_PDMA4_COUNT
,
947 .start
= VT1724_PDMA4_START
,
950 static const struct vt1724_pcm_reg vt1724_capture_spdif_reg
= {
951 .addr
= VT1724_MT_RDMA1_ADDR
,
952 .size
= VT1724_MT_RDMA1_SIZE
,
953 .count
= VT1724_MT_RDMA1_COUNT
,
954 .start
= VT1724_RDMA1_START
,
957 /* update spdif control bits; call with reg_lock */
958 static void update_spdif_bits(struct snd_ice1712
*ice
, unsigned int val
)
960 unsigned char cbit
, disabled
;
962 cbit
= inb(ICEREG1724(ice
, SPDIF_CFG
));
963 disabled
= cbit
& ~VT1724_CFG_SPDIF_OUT_EN
;
964 if (cbit
!= disabled
)
965 outb(disabled
, ICEREG1724(ice
, SPDIF_CFG
));
966 outw(val
, ICEMT1724(ice
, SPDIF_CTRL
));
967 if (cbit
!= disabled
)
968 outb(cbit
, ICEREG1724(ice
, SPDIF_CFG
));
969 outw(val
, ICEMT1724(ice
, SPDIF_CTRL
));
972 /* update SPDIF control bits according to the given rate */
973 static void update_spdif_rate(struct snd_ice1712
*ice
, unsigned int rate
)
975 unsigned int val
, nval
;
978 spin_lock_irqsave(&ice
->reg_lock
, flags
);
979 nval
= val
= inw(ICEMT1724(ice
, SPDIF_CTRL
));
983 case 48000: nval
|= 2 << 12; break;
984 case 32000: nval
|= 3 << 12; break;
985 case 88200: nval
|= 4 << 12; break;
986 case 96000: nval
|= 5 << 12; break;
987 case 192000: nval
|= 6 << 12; break;
988 case 176400: nval
|= 7 << 12; break;
991 update_spdif_bits(ice
, nval
);
992 spin_unlock_irqrestore(&ice
->reg_lock
, flags
);
995 static int snd_vt1724_playback_spdif_prepare(struct snd_pcm_substream
*substream
)
997 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
998 if (! ice
->force_pdma4
)
999 update_spdif_rate(ice
, substream
->runtime
->rate
);
1000 return snd_vt1724_pcm_prepare(substream
);
1003 static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream
*substream
)
1005 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1006 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1008 runtime
->private_data
= (void *)&vt1724_playback_spdif_reg
;
1009 ice
->playback_con_substream
= substream
;
1010 if (ice
->force_pdma4
) {
1011 runtime
->hw
= snd_vt1724_2ch_stereo
;
1012 set_rate_constraints(ice
, substream
);
1014 runtime
->hw
= snd_vt1724_spdif
;
1015 snd_pcm_set_sync(substream
);
1016 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
1017 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
1018 VT1724_BUFFER_ALIGN
);
1019 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
1020 VT1724_BUFFER_ALIGN
);
1021 if (ice
->spdif
.ops
.open
)
1022 ice
->spdif
.ops
.open(ice
, substream
);
1026 static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream
*substream
)
1028 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1031 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 0);
1032 ice
->playback_con_substream
= NULL
;
1033 if (ice
->spdif
.ops
.close
)
1034 ice
->spdif
.ops
.close(ice
, substream
);
1039 static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream
*substream
)
1041 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1042 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1044 runtime
->private_data
= (void *)&vt1724_capture_spdif_reg
;
1045 ice
->capture_con_substream
= substream
;
1046 if (ice
->force_rdma1
) {
1047 runtime
->hw
= snd_vt1724_2ch_stereo
;
1048 set_rate_constraints(ice
, substream
);
1050 runtime
->hw
= snd_vt1724_spdif
;
1051 snd_pcm_set_sync(substream
);
1052 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
1053 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
1054 VT1724_BUFFER_ALIGN
);
1055 snd_pcm_hw_constraint_step(runtime
, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
1056 VT1724_BUFFER_ALIGN
);
1057 if (ice
->spdif
.ops
.open
)
1058 ice
->spdif
.ops
.open(ice
, substream
);
1062 static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream
*substream
)
1064 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1067 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 0);
1068 ice
->capture_con_substream
= NULL
;
1069 if (ice
->spdif
.ops
.close
)
1070 ice
->spdif
.ops
.close(ice
, substream
);
1075 static struct snd_pcm_ops snd_vt1724_playback_spdif_ops
= {
1076 .open
= snd_vt1724_playback_spdif_open
,
1077 .close
= snd_vt1724_playback_spdif_close
,
1078 .ioctl
= snd_pcm_lib_ioctl
,
1079 .hw_params
= snd_vt1724_pcm_hw_params
,
1080 .hw_free
= snd_vt1724_pcm_hw_free
,
1081 .prepare
= snd_vt1724_playback_spdif_prepare
,
1082 .trigger
= snd_vt1724_pcm_trigger
,
1083 .pointer
= snd_vt1724_pcm_pointer
,
1086 static struct snd_pcm_ops snd_vt1724_capture_spdif_ops
= {
1087 .open
= snd_vt1724_capture_spdif_open
,
1088 .close
= snd_vt1724_capture_spdif_close
,
1089 .ioctl
= snd_pcm_lib_ioctl
,
1090 .hw_params
= snd_vt1724_pcm_hw_params
,
1091 .hw_free
= snd_vt1724_pcm_hw_free
,
1092 .prepare
= snd_vt1724_pcm_prepare
,
1093 .trigger
= snd_vt1724_pcm_trigger
,
1094 .pointer
= snd_vt1724_pcm_pointer
,
1098 static int __devinit
snd_vt1724_pcm_spdif(struct snd_ice1712
* ice
, int device
)
1101 struct snd_pcm
*pcm
;
1105 if (ice
->force_pdma4
||
1106 (ice
->eeprom
.data
[ICE_EEP2_SPDIF
] & VT1724_CFG_SPDIF_OUT_INT
)) {
1111 if (ice
->force_rdma1
||
1112 (ice
->eeprom
.data
[ICE_EEP2_SPDIF
] & VT1724_CFG_SPDIF_IN
)) {
1117 if (! play
&& ! capt
)
1118 return 0; /* no spdif device */
1120 if (ice
->force_pdma4
|| ice
->force_rdma1
)
1121 name
= "ICE1724 Secondary";
1123 name
= "IEC1724 IEC958";
1124 err
= snd_pcm_new(ice
->card
, name
, device
, play
, capt
, &pcm
);
1129 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1130 &snd_vt1724_playback_spdif_ops
);
1132 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
1133 &snd_vt1724_capture_spdif_ops
);
1135 pcm
->private_data
= ice
;
1136 pcm
->info_flags
= 0;
1137 strcpy(pcm
->name
, name
);
1139 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
,
1140 snd_dma_pci_data(ice
->pci
),
1150 * independent surround PCMs
1153 static const struct vt1724_pcm_reg vt1724_playback_dma_regs
[3] = {
1155 .addr
= VT1724_MT_PDMA1_ADDR
,
1156 .size
= VT1724_MT_PDMA1_SIZE
,
1157 .count
= VT1724_MT_PDMA1_COUNT
,
1158 .start
= VT1724_PDMA1_START
,
1161 .addr
= VT1724_MT_PDMA2_ADDR
,
1162 .size
= VT1724_MT_PDMA2_SIZE
,
1163 .count
= VT1724_MT_PDMA2_COUNT
,
1164 .start
= VT1724_PDMA2_START
,
1167 .addr
= VT1724_MT_PDMA3_ADDR
,
1168 .size
= VT1724_MT_PDMA3_SIZE
,
1169 .count
= VT1724_MT_PDMA3_COUNT
,
1170 .start
= VT1724_PDMA3_START
,
1174 static int snd_vt1724_playback_indep_prepare(struct snd_pcm_substream
*substream
)
1176 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1179 spin_lock_irq(&ice
->reg_lock
);
1180 val
= 3 - substream
->number
;
1181 if (inb(ICEMT1724(ice
, BURST
)) < val
)
1182 outb(val
, ICEMT1724(ice
, BURST
));
1183 spin_unlock_irq(&ice
->reg_lock
);
1184 return snd_vt1724_pcm_prepare(substream
);
1187 static int snd_vt1724_playback_indep_open(struct snd_pcm_substream
*substream
)
1189 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1190 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1192 mutex_lock(&ice
->open_mutex
);
1193 /* already used by PDMA0? */
1194 if (ice
->pcm_reserved
[substream
->number
]) {
1195 mutex_unlock(&ice
->open_mutex
);
1196 return -EBUSY
; /* FIXME: should handle blocking mode properly */
1198 mutex_unlock(&ice
->open_mutex
);
1199 runtime
->private_data
= (void *)&vt1724_playback_dma_regs
[substream
->number
];
1200 ice
->playback_con_substream_ds
[substream
->number
] = substream
;
1201 runtime
->hw
= snd_vt1724_2ch_stereo
;
1202 snd_pcm_set_sync(substream
);
1203 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
1204 set_rate_constraints(ice
, substream
);
1208 static int snd_vt1724_playback_indep_close(struct snd_pcm_substream
*substream
)
1210 struct snd_ice1712
*ice
= snd_pcm_substream_chip(substream
);
1213 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 0);
1214 ice
->playback_con_substream_ds
[substream
->number
] = NULL
;
1215 ice
->pcm_reserved
[substream
->number
] = NULL
;
1220 static struct snd_pcm_ops snd_vt1724_playback_indep_ops
= {
1221 .open
= snd_vt1724_playback_indep_open
,
1222 .close
= snd_vt1724_playback_indep_close
,
1223 .ioctl
= snd_pcm_lib_ioctl
,
1224 .hw_params
= snd_vt1724_pcm_hw_params
,
1225 .hw_free
= snd_vt1724_pcm_hw_free
,
1226 .prepare
= snd_vt1724_playback_indep_prepare
,
1227 .trigger
= snd_vt1724_pcm_trigger
,
1228 .pointer
= snd_vt1724_pcm_pointer
,
1232 static int __devinit
snd_vt1724_pcm_indep(struct snd_ice1712
* ice
, int device
)
1234 struct snd_pcm
*pcm
;
1238 play
= ice
->num_total_dacs
/ 2 - 1;
1242 err
= snd_pcm_new(ice
->card
, "ICE1724 Surrounds", device
, play
, 0, &pcm
);
1246 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1247 &snd_vt1724_playback_indep_ops
);
1249 pcm
->private_data
= ice
;
1250 pcm
->info_flags
= 0;
1251 strcpy(pcm
->name
, "ICE1724 Surround PCM");
1253 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
,
1254 snd_dma_pci_data(ice
->pci
),
1267 static int __devinit
snd_vt1724_ac97_mixer(struct snd_ice1712
* ice
)
1271 if (! (ice
->eeprom
.data
[ICE_EEP2_ACLINK
] & VT1724_CFG_PRO_I2S
)) {
1272 struct snd_ac97_bus
*pbus
;
1273 struct snd_ac97_template ac97
;
1274 static struct snd_ac97_bus_ops ops
= {
1275 .write
= snd_vt1724_ac97_write
,
1276 .read
= snd_vt1724_ac97_read
,
1280 outb(inb(ICEMT1724(ice
, AC97_CMD
)) | 0x80, ICEMT1724(ice
, AC97_CMD
));
1281 mdelay(5); /* FIXME */
1282 outb(inb(ICEMT1724(ice
, AC97_CMD
)) & ~0x80, ICEMT1724(ice
, AC97_CMD
));
1284 if ((err
= snd_ac97_bus(ice
->card
, 0, &ops
, NULL
, &pbus
)) < 0)
1286 memset(&ac97
, 0, sizeof(ac97
));
1287 ac97
.private_data
= ice
;
1288 if ((err
= snd_ac97_mixer(pbus
, &ac97
, &ice
->ac97
)) < 0)
1289 printk(KERN_WARNING
"ice1712: cannot initialize pro ac97, skipped\n");
1293 /* I2S mixer only */
1294 strcat(ice
->card
->mixername
, "ICE1724 - multitrack");
1302 static inline unsigned int eeprom_triple(struct snd_ice1712
*ice
, int idx
)
1304 return (unsigned int)ice
->eeprom
.data
[idx
] | \
1305 ((unsigned int)ice
->eeprom
.data
[idx
+ 1] << 8) | \
1306 ((unsigned int)ice
->eeprom
.data
[idx
+ 2] << 16);
1309 static void snd_vt1724_proc_read(struct snd_info_entry
*entry
,
1310 struct snd_info_buffer
*buffer
)
1312 struct snd_ice1712
*ice
= entry
->private_data
;
1315 snd_iprintf(buffer
, "%s\n\n", ice
->card
->longname
);
1316 snd_iprintf(buffer
, "EEPROM:\n");
1318 snd_iprintf(buffer
, " Subvendor : 0x%x\n", ice
->eeprom
.subvendor
);
1319 snd_iprintf(buffer
, " Size : %i bytes\n", ice
->eeprom
.size
);
1320 snd_iprintf(buffer
, " Version : %i\n", ice
->eeprom
.version
);
1321 snd_iprintf(buffer
, " System Config : 0x%x\n",
1322 ice
->eeprom
.data
[ICE_EEP2_SYSCONF
]);
1323 snd_iprintf(buffer
, " ACLink : 0x%x\n",
1324 ice
->eeprom
.data
[ICE_EEP2_ACLINK
]);
1325 snd_iprintf(buffer
, " I2S : 0x%x\n",
1326 ice
->eeprom
.data
[ICE_EEP2_I2S
]);
1327 snd_iprintf(buffer
, " S/PDIF : 0x%x\n",
1328 ice
->eeprom
.data
[ICE_EEP2_SPDIF
]);
1329 snd_iprintf(buffer
, " GPIO direction : 0x%x\n",
1330 ice
->eeprom
.gpiodir
);
1331 snd_iprintf(buffer
, " GPIO mask : 0x%x\n",
1332 ice
->eeprom
.gpiomask
);
1333 snd_iprintf(buffer
, " GPIO state : 0x%x\n",
1334 ice
->eeprom
.gpiostate
);
1335 for (idx
= 0x12; idx
< ice
->eeprom
.size
; idx
++)
1336 snd_iprintf(buffer
, " Extra #%02i : 0x%x\n",
1337 idx
, ice
->eeprom
.data
[idx
]);
1339 snd_iprintf(buffer
, "\nRegisters:\n");
1341 snd_iprintf(buffer
, " PSDOUT03 : 0x%08x\n",
1342 (unsigned)inl(ICEMT1724(ice
, ROUTE_PLAYBACK
)));
1343 for (idx
= 0x0; idx
< 0x20 ; idx
++)
1344 snd_iprintf(buffer
, " CCS%02x : 0x%02x\n",
1345 idx
, inb(ice
->port
+idx
));
1346 for (idx
= 0x0; idx
< 0x30 ; idx
++)
1347 snd_iprintf(buffer
, " MT%02x : 0x%02x\n",
1348 idx
, inb(ice
->profi_port
+idx
));
1351 static void __devinit
snd_vt1724_proc_init(struct snd_ice1712
* ice
)
1353 struct snd_info_entry
*entry
;
1355 if (! snd_card_proc_new(ice
->card
, "ice1724", &entry
))
1356 snd_info_set_text_ops(entry
, ice
, snd_vt1724_proc_read
);
1363 static int snd_vt1724_eeprom_info(struct snd_kcontrol
*kcontrol
,
1364 struct snd_ctl_elem_info
*uinfo
)
1366 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BYTES
;
1367 uinfo
->count
= sizeof(struct snd_ice1712_eeprom
);
1371 static int snd_vt1724_eeprom_get(struct snd_kcontrol
*kcontrol
,
1372 struct snd_ctl_elem_value
*ucontrol
)
1374 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1376 memcpy(ucontrol
->value
.bytes
.data
, &ice
->eeprom
, sizeof(ice
->eeprom
));
1380 static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata
= {
1381 .iface
= SNDRV_CTL_ELEM_IFACE_CARD
,
1382 .name
= "ICE1724 EEPROM",
1383 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1384 .info
= snd_vt1724_eeprom_info
,
1385 .get
= snd_vt1724_eeprom_get
1390 static int snd_vt1724_spdif_info(struct snd_kcontrol
*kcontrol
,
1391 struct snd_ctl_elem_info
*uinfo
)
1393 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
1398 static unsigned int encode_spdif_bits(struct snd_aes_iec958
*diga
)
1400 unsigned int val
, rbits
;
1402 val
= diga
->status
[0] & 0x03; /* professional, non-audio */
1405 if ((diga
->status
[0] & IEC958_AES0_PRO_EMPHASIS
) ==
1406 IEC958_AES0_PRO_EMPHASIS_5015
)
1408 rbits
= (diga
->status
[4] >> 3) & 0x0f;
1411 case 2: val
|= 5 << 12; break; /* 96k */
1412 case 3: val
|= 6 << 12; break; /* 192k */
1413 case 10: val
|= 4 << 12; break; /* 88.2k */
1414 case 11: val
|= 7 << 12; break; /* 176.4k */
1417 switch (diga
->status
[0] & IEC958_AES0_PRO_FS
) {
1418 case IEC958_AES0_PRO_FS_44100
:
1420 case IEC958_AES0_PRO_FS_32000
:
1430 val
|= diga
->status
[1] & 0x04; /* copyright */
1431 if ((diga
->status
[0] & IEC958_AES0_CON_EMPHASIS
) ==
1432 IEC958_AES0_CON_EMPHASIS_5015
)
1434 val
|= (unsigned int)(diga
->status
[1] & 0x3f) << 4; /* category */
1435 val
|= (unsigned int)(diga
->status
[3] & IEC958_AES3_CON_FS
) << 12; /* fs */
1440 static void decode_spdif_bits(struct snd_aes_iec958
*diga
, unsigned int val
)
1442 memset(diga
->status
, 0, sizeof(diga
->status
));
1443 diga
->status
[0] = val
& 0x03; /* professional, non-audio */
1446 if (val
& (1U << 3))
1447 diga
->status
[0] |= IEC958_AES0_PRO_EMPHASIS_5015
;
1448 switch ((val
>> 12) & 0x7) {
1452 diga
->status
[0] |= IEC958_AES0_PRO_FS_32000
;
1455 diga
->status
[0] |= IEC958_AES0_PRO_FS_48000
;
1460 diga
->status
[0] |= val
& (1U << 2); /* copyright */
1461 if (val
& (1U << 3))
1462 diga
->status
[0] |= IEC958_AES0_CON_EMPHASIS_5015
;
1463 diga
->status
[1] |= (val
>> 4) & 0x3f; /* category */
1464 diga
->status
[3] |= (val
>> 12) & 0x07; /* fs */
1468 static int snd_vt1724_spdif_default_get(struct snd_kcontrol
*kcontrol
,
1469 struct snd_ctl_elem_value
*ucontrol
)
1471 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1473 val
= inw(ICEMT1724(ice
, SPDIF_CTRL
));
1474 decode_spdif_bits(&ucontrol
->value
.iec958
, val
);
1478 static int snd_vt1724_spdif_default_put(struct snd_kcontrol
*kcontrol
,
1479 struct snd_ctl_elem_value
*ucontrol
)
1481 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1482 unsigned int val
, old
;
1484 val
= encode_spdif_bits(&ucontrol
->value
.iec958
);
1485 spin_lock_irq(&ice
->reg_lock
);
1486 old
= inw(ICEMT1724(ice
, SPDIF_CTRL
));
1488 update_spdif_bits(ice
, val
);
1489 spin_unlock_irq(&ice
->reg_lock
);
1490 return (val
!= old
);
1493 static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata
=
1495 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1496 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,DEFAULT
),
1497 .info
= snd_vt1724_spdif_info
,
1498 .get
= snd_vt1724_spdif_default_get
,
1499 .put
= snd_vt1724_spdif_default_put
1502 static int snd_vt1724_spdif_maskc_get(struct snd_kcontrol
*kcontrol
,
1503 struct snd_ctl_elem_value
*ucontrol
)
1505 ucontrol
->value
.iec958
.status
[0] = IEC958_AES0_NONAUDIO
|
1506 IEC958_AES0_PROFESSIONAL
|
1507 IEC958_AES0_CON_NOT_COPYRIGHT
|
1508 IEC958_AES0_CON_EMPHASIS
;
1509 ucontrol
->value
.iec958
.status
[1] = IEC958_AES1_CON_ORIGINAL
|
1510 IEC958_AES1_CON_CATEGORY
;
1511 ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS
;
1515 static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol
*kcontrol
,
1516 struct snd_ctl_elem_value
*ucontrol
)
1518 ucontrol
->value
.iec958
.status
[0] = IEC958_AES0_NONAUDIO
|
1519 IEC958_AES0_PROFESSIONAL
|
1520 IEC958_AES0_PRO_FS
|
1521 IEC958_AES0_PRO_EMPHASIS
;
1525 static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata
=
1527 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1528 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1529 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,CON_MASK
),
1530 .info
= snd_vt1724_spdif_info
,
1531 .get
= snd_vt1724_spdif_maskc_get
,
1534 static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata
=
1536 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1537 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1538 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,PRO_MASK
),
1539 .info
= snd_vt1724_spdif_info
,
1540 .get
= snd_vt1724_spdif_maskp_get
,
1543 #define snd_vt1724_spdif_sw_info snd_ctl_boolean_mono_info
1545 static int snd_vt1724_spdif_sw_get(struct snd_kcontrol
*kcontrol
,
1546 struct snd_ctl_elem_value
*ucontrol
)
1548 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1549 ucontrol
->value
.integer
.value
[0] = inb(ICEREG1724(ice
, SPDIF_CFG
)) &
1550 VT1724_CFG_SPDIF_OUT_EN
? 1 : 0;
1554 static int snd_vt1724_spdif_sw_put(struct snd_kcontrol
*kcontrol
,
1555 struct snd_ctl_elem_value
*ucontrol
)
1557 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1558 unsigned char old
, val
;
1560 spin_lock_irq(&ice
->reg_lock
);
1561 old
= val
= inb(ICEREG1724(ice
, SPDIF_CFG
));
1562 val
&= ~VT1724_CFG_SPDIF_OUT_EN
;
1563 if (ucontrol
->value
.integer
.value
[0])
1564 val
|= VT1724_CFG_SPDIF_OUT_EN
;
1566 outb(val
, ICEREG1724(ice
, SPDIF_CFG
));
1567 spin_unlock_irq(&ice
->reg_lock
);
1571 static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata
=
1573 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1574 /* FIXME: the following conflict with IEC958 Playback Route */
1575 // .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),
1576 .name
= SNDRV_CTL_NAME_IEC958("Output ",NONE
,SWITCH
),
1577 .info
= snd_vt1724_spdif_sw_info
,
1578 .get
= snd_vt1724_spdif_sw_get
,
1579 .put
= snd_vt1724_spdif_sw_put
1583 #if 0 /* NOT USED YET */
1585 * GPIO access from extern
1588 #define snd_vt1724_gpio_info snd_ctl_boolean_mono_info
1590 int snd_vt1724_gpio_get(struct snd_kcontrol
*kcontrol
,
1591 struct snd_ctl_elem_value
*ucontrol
)
1593 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1594 int shift
= kcontrol
->private_value
& 0xff;
1595 int invert
= (kcontrol
->private_value
& (1<<24)) ? 1 : 0;
1597 snd_ice1712_save_gpio_status(ice
);
1598 ucontrol
->value
.integer
.value
[0] =
1599 (snd_ice1712_gpio_read(ice
) & (1 << shift
) ? 1 : 0) ^ invert
;
1600 snd_ice1712_restore_gpio_status(ice
);
1604 int snd_ice1712_gpio_put(struct snd_kcontrol
*kcontrol
,
1605 struct snd_ctl_elem_value
*ucontrol
)
1607 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1608 int shift
= kcontrol
->private_value
& 0xff;
1609 int invert
= (kcontrol
->private_value
& (1<<24)) ? mask
: 0;
1610 unsigned int val
, nval
;
1612 if (kcontrol
->private_value
& (1 << 31))
1614 nval
= (ucontrol
->value
.integer
.value
[0] ? (1 << shift
) : 0) ^ invert
;
1615 snd_ice1712_save_gpio_status(ice
);
1616 val
= snd_ice1712_gpio_read(ice
);
1617 nval
|= val
& ~(1 << shift
);
1619 snd_ice1712_gpio_write(ice
, nval
);
1620 snd_ice1712_restore_gpio_status(ice
);
1623 #endif /* NOT USED YET */
1628 static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol
*kcontrol
,
1629 struct snd_ctl_elem_info
*uinfo
)
1631 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1633 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1635 uinfo
->value
.enumerated
.items
= ice
->hw_rates
->count
+ 1;
1636 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
1637 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
1638 if (uinfo
->value
.enumerated
.item
== uinfo
->value
.enumerated
.items
- 1)
1639 strcpy(uinfo
->value
.enumerated
.name
, "IEC958 Input");
1641 sprintf(uinfo
->value
.enumerated
.name
, "%d",
1642 ice
->hw_rates
->list
[uinfo
->value
.enumerated
.item
]);
1646 static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol
*kcontrol
,
1647 struct snd_ctl_elem_value
*ucontrol
)
1649 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1650 unsigned int i
, rate
;
1652 spin_lock_irq(&ice
->reg_lock
);
1653 if (ice
->is_spdif_master(ice
)) {
1654 ucontrol
->value
.enumerated
.item
[0] = ice
->hw_rates
->count
;
1656 rate
= ice
->get_rate(ice
);
1657 ucontrol
->value
.enumerated
.item
[0] = 0;
1658 for (i
= 0; i
< ice
->hw_rates
->count
; i
++) {
1659 if (ice
->hw_rates
->list
[i
] == rate
) {
1660 ucontrol
->value
.enumerated
.item
[0] = i
;
1665 spin_unlock_irq(&ice
->reg_lock
);
1669 /* setting clock to external - SPDIF */
1670 static void stdclock_set_spdif_clock(struct snd_ice1712
*ice
)
1673 unsigned char i2s_oval
;
1674 oval
= inb(ICEMT1724(ice
, RATE
));
1675 outb(oval
| VT1724_SPDIF_MASTER
, ICEMT1724(ice
, RATE
));
1677 i2s_oval
= inb(ICEMT1724(ice
, I2S_FORMAT
));
1678 outb(i2s_oval
& ~VT1724_MT_I2S_MCLK_128X
, ICEMT1724(ice
, I2S_FORMAT
));
1681 static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol
*kcontrol
,
1682 struct snd_ctl_elem_value
*ucontrol
)
1684 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1685 unsigned int old_rate
, new_rate
;
1686 unsigned int item
= ucontrol
->value
.enumerated
.item
[0];
1687 unsigned int spdif
= ice
->hw_rates
->count
;
1692 spin_lock_irq(&ice
->reg_lock
);
1693 if (ice
->is_spdif_master(ice
))
1696 old_rate
= ice
->get_rate(ice
);
1697 if (item
== spdif
) {
1698 /* switching to external clock via SPDIF */
1699 ice
->set_spdif_clock(ice
);
1702 /* internal on-card clock */
1703 new_rate
= ice
->hw_rates
->list
[item
];
1704 ice
->pro_rate_default
= new_rate
;
1705 spin_unlock_irq(&ice
->reg_lock
);
1706 snd_vt1724_set_pro_rate(ice
, ice
->pro_rate_default
, 1);
1707 spin_lock_irq(&ice
->reg_lock
);
1709 spin_unlock_irq(&ice
->reg_lock
);
1711 /* the first reset to the SPDIF master mode? */
1712 if (old_rate
!= new_rate
&& !new_rate
) {
1713 /* notify akm chips as well */
1715 if (ice
->gpio
.set_pro_rate
)
1716 ice
->gpio
.set_pro_rate(ice
, 0);
1717 for (i
= 0; i
< ice
->akm_codecs
; i
++) {
1718 if (ice
->akm
[i
].ops
.set_rate_val
)
1719 ice
->akm
[i
].ops
.set_rate_val(&ice
->akm
[i
], 0);
1722 return old_rate
!= new_rate
;
1725 static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata
= {
1726 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1727 .name
= "Multi Track Internal Clock",
1728 .info
= snd_vt1724_pro_internal_clock_info
,
1729 .get
= snd_vt1724_pro_internal_clock_get
,
1730 .put
= snd_vt1724_pro_internal_clock_put
1733 #define snd_vt1724_pro_rate_locking_info snd_ctl_boolean_mono_info
1735 static int snd_vt1724_pro_rate_locking_get(struct snd_kcontrol
*kcontrol
,
1736 struct snd_ctl_elem_value
*ucontrol
)
1738 ucontrol
->value
.integer
.value
[0] = PRO_RATE_LOCKED
;
1742 static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol
*kcontrol
,
1743 struct snd_ctl_elem_value
*ucontrol
)
1745 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1746 int change
= 0, nval
;
1748 nval
= ucontrol
->value
.integer
.value
[0] ? 1 : 0;
1749 spin_lock_irq(&ice
->reg_lock
);
1750 change
= PRO_RATE_LOCKED
!= nval
;
1751 PRO_RATE_LOCKED
= nval
;
1752 spin_unlock_irq(&ice
->reg_lock
);
1756 static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata
= {
1757 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1758 .name
= "Multi Track Rate Locking",
1759 .info
= snd_vt1724_pro_rate_locking_info
,
1760 .get
= snd_vt1724_pro_rate_locking_get
,
1761 .put
= snd_vt1724_pro_rate_locking_put
1764 #define snd_vt1724_pro_rate_reset_info snd_ctl_boolean_mono_info
1766 static int snd_vt1724_pro_rate_reset_get(struct snd_kcontrol
*kcontrol
,
1767 struct snd_ctl_elem_value
*ucontrol
)
1769 ucontrol
->value
.integer
.value
[0] = PRO_RATE_RESET
? 1 : 0;
1773 static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol
*kcontrol
,
1774 struct snd_ctl_elem_value
*ucontrol
)
1776 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1777 int change
= 0, nval
;
1779 nval
= ucontrol
->value
.integer
.value
[0] ? 1 : 0;
1780 spin_lock_irq(&ice
->reg_lock
);
1781 change
= PRO_RATE_RESET
!= nval
;
1782 PRO_RATE_RESET
= nval
;
1783 spin_unlock_irq(&ice
->reg_lock
);
1787 static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata
= {
1788 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1789 .name
= "Multi Track Rate Reset",
1790 .info
= snd_vt1724_pro_rate_reset_info
,
1791 .get
= snd_vt1724_pro_rate_reset_get
,
1792 .put
= snd_vt1724_pro_rate_reset_put
1799 static int snd_vt1724_pro_route_info(struct snd_kcontrol
*kcontrol
,
1800 struct snd_ctl_elem_info
*uinfo
)
1802 static char *texts
[] = {
1804 "H/W In 0", "H/W In 1", /* 1-2 */
1805 "IEC958 In L", "IEC958 In R", /* 3-4 */
1808 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1810 uinfo
->value
.enumerated
.items
= 5;
1811 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
1812 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
1813 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1817 static inline int analog_route_shift(int idx
)
1819 return (idx
% 2) * 12 + ((idx
/ 2) * 3) + 8;
1822 static inline int digital_route_shift(int idx
)
1827 static int get_route_val(struct snd_ice1712
*ice
, int shift
)
1830 unsigned char eitem
;
1831 static const unsigned char xlate
[8] = {
1832 0, 255, 1, 2, 255, 255, 3, 4,
1835 val
= inl(ICEMT1724(ice
, ROUTE_PLAYBACK
));
1837 val
&= 7; //we now have 3 bits per output
1846 static int put_route_val(struct snd_ice1712
*ice
, unsigned int val
, int shift
)
1848 unsigned int old_val
, nval
;
1850 static const unsigned char xroute
[8] = {
1852 2, /* PSDIN0 Left */
1853 3, /* PSDIN0 Right */
1855 7, /* SPDIN Right */
1858 nval
= xroute
[val
% 5];
1859 val
= old_val
= inl(ICEMT1724(ice
, ROUTE_PLAYBACK
));
1860 val
&= ~(0x07 << shift
);
1861 val
|= nval
<< shift
;
1862 change
= val
!= old_val
;
1864 outl(val
, ICEMT1724(ice
, ROUTE_PLAYBACK
));
1868 static int snd_vt1724_pro_route_analog_get(struct snd_kcontrol
*kcontrol
,
1869 struct snd_ctl_elem_value
*ucontrol
)
1871 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1872 int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1873 ucontrol
->value
.enumerated
.item
[0] =
1874 get_route_val(ice
, analog_route_shift(idx
));
1878 static int snd_vt1724_pro_route_analog_put(struct snd_kcontrol
*kcontrol
,
1879 struct snd_ctl_elem_value
*ucontrol
)
1881 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1882 int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1883 return put_route_val(ice
, ucontrol
->value
.enumerated
.item
[0],
1884 analog_route_shift(idx
));
1887 static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol
*kcontrol
,
1888 struct snd_ctl_elem_value
*ucontrol
)
1890 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1891 int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1892 ucontrol
->value
.enumerated
.item
[0] =
1893 get_route_val(ice
, digital_route_shift(idx
));
1897 static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol
*kcontrol
,
1898 struct snd_ctl_elem_value
*ucontrol
)
1900 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1901 int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1902 return put_route_val(ice
, ucontrol
->value
.enumerated
.item
[0],
1903 digital_route_shift(idx
));
1906 static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata
= {
1907 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1908 .name
= "H/W Playback Route",
1909 .info
= snd_vt1724_pro_route_info
,
1910 .get
= snd_vt1724_pro_route_analog_get
,
1911 .put
= snd_vt1724_pro_route_analog_put
,
1914 static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata
= {
1915 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1916 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Route",
1917 .info
= snd_vt1724_pro_route_info
,
1918 .get
= snd_vt1724_pro_route_spdif_get
,
1919 .put
= snd_vt1724_pro_route_spdif_put
,
1924 static int snd_vt1724_pro_peak_info(struct snd_kcontrol
*kcontrol
,
1925 struct snd_ctl_elem_info
*uinfo
)
1927 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
1928 uinfo
->count
= 22; /* FIXME: for compatibility with ice1712... */
1929 uinfo
->value
.integer
.min
= 0;
1930 uinfo
->value
.integer
.max
= 255;
1934 static int snd_vt1724_pro_peak_get(struct snd_kcontrol
*kcontrol
,
1935 struct snd_ctl_elem_value
*ucontrol
)
1937 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
1940 spin_lock_irq(&ice
->reg_lock
);
1941 for (idx
= 0; idx
< 22; idx
++) {
1942 outb(idx
, ICEMT1724(ice
, MONITOR_PEAKINDEX
));
1943 ucontrol
->value
.integer
.value
[idx
] =
1944 inb(ICEMT1724(ice
, MONITOR_PEAKDATA
));
1946 spin_unlock_irq(&ice
->reg_lock
);
1950 static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata
= {
1951 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1952 .name
= "Multi Track Peak",
1953 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
1954 .info
= snd_vt1724_pro_peak_info
,
1955 .get
= snd_vt1724_pro_peak_get
1962 static struct snd_ice1712_card_info no_matched __devinitdata
;
1964 static struct snd_ice1712_card_info
*card_tables
[] __devinitdata
= {
1965 snd_vt1724_revo_cards
,
1966 snd_vt1724_amp_cards
,
1967 snd_vt1724_aureon_cards
,
1968 snd_vt1720_mobo_cards
,
1969 snd_vt1720_pontis_cards
,
1970 snd_vt1724_prodigy_hifi_cards
,
1971 snd_vt1724_prodigy192_cards
,
1972 snd_vt1724_juli_cards
,
1973 snd_vt1724_phase_cards
,
1974 snd_vt1724_wtm_cards
,
1975 snd_vt1724_se_cards
,
1983 static void wait_i2c_busy(struct snd_ice1712
*ice
)
1986 while ((inb(ICEREG1724(ice
, I2C_CTRL
)) & VT1724_I2C_BUSY
) && t
--)
1989 printk(KERN_ERR
"ice1724: i2c busy timeout\n");
1992 unsigned char snd_vt1724_read_i2c(struct snd_ice1712
*ice
,
1993 unsigned char dev
, unsigned char addr
)
1997 mutex_lock(&ice
->i2c_mutex
);
1999 outb(addr
, ICEREG1724(ice
, I2C_BYTE_ADDR
));
2000 outb(dev
& ~VT1724_I2C_WRITE
, ICEREG1724(ice
, I2C_DEV_ADDR
));
2002 val
= inb(ICEREG1724(ice
, I2C_DATA
));
2003 mutex_unlock(&ice
->i2c_mutex
);
2004 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
2008 void snd_vt1724_write_i2c(struct snd_ice1712
*ice
,
2009 unsigned char dev
, unsigned char addr
, unsigned char data
)
2011 mutex_lock(&ice
->i2c_mutex
);
2013 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
2014 outb(addr
, ICEREG1724(ice
, I2C_BYTE_ADDR
));
2015 outb(data
, ICEREG1724(ice
, I2C_DATA
));
2016 outb(dev
| VT1724_I2C_WRITE
, ICEREG1724(ice
, I2C_DEV_ADDR
));
2018 mutex_unlock(&ice
->i2c_mutex
);
2021 static int __devinit
snd_vt1724_read_eeprom(struct snd_ice1712
*ice
,
2022 const char *modelname
)
2024 const int dev
= 0xa0; /* EEPROM device address */
2025 unsigned int i
, size
;
2026 struct snd_ice1712_card_info
* const *tbl
, *c
;
2028 if (! modelname
|| ! *modelname
) {
2029 ice
->eeprom
.subvendor
= 0;
2030 if ((inb(ICEREG1724(ice
, I2C_CTRL
)) & VT1724_I2C_EEPROM
) != 0)
2031 ice
->eeprom
.subvendor
=
2032 (snd_vt1724_read_i2c(ice
, dev
, 0x00) << 0) |
2033 (snd_vt1724_read_i2c(ice
, dev
, 0x01) << 8) |
2034 (snd_vt1724_read_i2c(ice
, dev
, 0x02) << 16) |
2035 (snd_vt1724_read_i2c(ice
, dev
, 0x03) << 24);
2036 if (ice
->eeprom
.subvendor
== 0 ||
2037 ice
->eeprom
.subvendor
== (unsigned int)-1) {
2038 /* invalid subvendor from EEPROM, try the PCI
2039 * subststem ID instead
2042 pci_read_config_word(ice
->pci
, PCI_SUBSYSTEM_VENDOR_ID
,
2044 pci_read_config_word(ice
->pci
, PCI_SUBSYSTEM_ID
, &device
);
2045 ice
->eeprom
.subvendor
=
2046 ((unsigned int)swab16(vendor
) << 16) | swab16(device
);
2047 if (ice
->eeprom
.subvendor
== 0 ||
2048 ice
->eeprom
.subvendor
== (unsigned int)-1) {
2049 printk(KERN_ERR
"ice1724: No valid ID is found\n");
2054 for (tbl
= card_tables
; *tbl
; tbl
++) {
2055 for (c
= *tbl
; c
->subvendor
; c
++) {
2056 if (modelname
&& c
->model
&&
2057 ! strcmp(modelname
, c
->model
)) {
2058 printk(KERN_INFO
"ice1724: Using board model %s\n",
2060 ice
->eeprom
.subvendor
= c
->subvendor
;
2061 } else if (c
->subvendor
!= ice
->eeprom
.subvendor
)
2063 if (! c
->eeprom_size
|| ! c
->eeprom_data
)
2065 /* if the EEPROM is given by the driver, use it */
2066 snd_printdd("using the defined eeprom..\n");
2067 ice
->eeprom
.version
= 2;
2068 ice
->eeprom
.size
= c
->eeprom_size
+ 6;
2069 memcpy(ice
->eeprom
.data
, c
->eeprom_data
, c
->eeprom_size
);
2073 printk(KERN_WARNING
"ice1724: No matching model found for ID 0x%x\n",
2074 ice
->eeprom
.subvendor
);
2077 ice
->eeprom
.size
= snd_vt1724_read_i2c(ice
, dev
, 0x04);
2078 if (ice
->eeprom
.size
< 6)
2079 ice
->eeprom
.size
= 32;
2080 else if (ice
->eeprom
.size
> 32) {
2081 printk(KERN_ERR
"ice1724: Invalid EEPROM (size = %i)\n",
2085 ice
->eeprom
.version
= snd_vt1724_read_i2c(ice
, dev
, 0x05);
2086 if (ice
->eeprom
.version
!= 2)
2087 printk(KERN_WARNING
"ice1724: Invalid EEPROM version %i\n",
2088 ice
->eeprom
.version
);
2089 size
= ice
->eeprom
.size
- 6;
2090 for (i
= 0; i
< size
; i
++)
2091 ice
->eeprom
.data
[i
] = snd_vt1724_read_i2c(ice
, dev
, i
+ 6);
2094 ice
->eeprom
.gpiomask
= eeprom_triple(ice
, ICE_EEP2_GPIO_MASK
);
2095 ice
->eeprom
.gpiostate
= eeprom_triple(ice
, ICE_EEP2_GPIO_STATE
);
2096 ice
->eeprom
.gpiodir
= eeprom_triple(ice
, ICE_EEP2_GPIO_DIR
);
2103 static void __devinit
snd_vt1724_chip_reset(struct snd_ice1712
*ice
)
2105 outb(VT1724_RESET
, ICEREG1724(ice
, CONTROL
));
2107 outb(0, ICEREG1724(ice
, CONTROL
));
2111 static int __devinit
snd_vt1724_chip_init(struct snd_ice1712
*ice
)
2113 outb(ice
->eeprom
.data
[ICE_EEP2_SYSCONF
], ICEREG1724(ice
, SYS_CFG
));
2114 outb(ice
->eeprom
.data
[ICE_EEP2_ACLINK
], ICEREG1724(ice
, AC97_CFG
));
2115 outb(ice
->eeprom
.data
[ICE_EEP2_I2S
], ICEREG1724(ice
, I2S_FEATURES
));
2116 outb(ice
->eeprom
.data
[ICE_EEP2_SPDIF
], ICEREG1724(ice
, SPDIF_CFG
));
2118 ice
->gpio
.write_mask
= ice
->eeprom
.gpiomask
;
2119 ice
->gpio
.direction
= ice
->eeprom
.gpiodir
;
2120 snd_vt1724_set_gpio_mask(ice
, ice
->eeprom
.gpiomask
);
2121 snd_vt1724_set_gpio_dir(ice
, ice
->eeprom
.gpiodir
);
2122 snd_vt1724_set_gpio_data(ice
, ice
->eeprom
.gpiostate
);
2124 outb(0, ICEREG1724(ice
, POWERDOWN
));
2129 static int __devinit
snd_vt1724_spdif_build_controls(struct snd_ice1712
*ice
)
2132 struct snd_kcontrol
*kctl
;
2134 snd_assert(ice
->pcm
!= NULL
, return -EIO
);
2136 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route
, ice
));
2140 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_spdif_switch
, ice
));
2144 err
= snd_ctl_add(ice
->card
, kctl
= snd_ctl_new1(&snd_vt1724_spdif_default
, ice
));
2147 kctl
->id
.device
= ice
->pcm
->device
;
2148 err
= snd_ctl_add(ice
->card
, kctl
= snd_ctl_new1(&snd_vt1724_spdif_maskc
, ice
));
2151 kctl
->id
.device
= ice
->pcm
->device
;
2152 err
= snd_ctl_add(ice
->card
, kctl
= snd_ctl_new1(&snd_vt1724_spdif_maskp
, ice
));
2155 kctl
->id
.device
= ice
->pcm
->device
;
2156 #if 0 /* use default only */
2157 err
= snd_ctl_add(ice
->card
, kctl
= snd_ctl_new1(&snd_vt1724_spdif_stream
, ice
));
2160 kctl
->id
.device
= ice
->pcm
->device
;
2161 ice
->spdif
.stream_ctl
= kctl
;
2167 static int __devinit
snd_vt1724_build_controls(struct snd_ice1712
*ice
)
2171 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_eeprom
, ice
));
2174 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_pro_internal_clock
, ice
));
2178 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_pro_rate_locking
, ice
));
2181 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_pro_rate_reset
, ice
));
2185 if (ice
->num_total_dacs
> 0) {
2186 struct snd_kcontrol_new tmp
= snd_vt1724_mixer_pro_analog_route
;
2187 tmp
.count
= ice
->num_total_dacs
;
2188 if (ice
->vt1720
&& tmp
.count
> 2)
2190 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&tmp
, ice
));
2195 err
= snd_ctl_add(ice
->card
, snd_ctl_new1(&snd_vt1724_mixer_pro_peak
, ice
));
2202 static int snd_vt1724_free(struct snd_ice1712
*ice
)
2206 /* mask all interrupts */
2207 outb(0xff, ICEMT1724(ice
, DMA_INT_MASK
));
2208 outb(0xff, ICEREG1724(ice
, IRQMASK
));
2212 free_irq(ice
->irq
, ice
);
2213 pci_release_regions(ice
->pci
);
2214 snd_ice1712_akm4xxx_free(ice
);
2215 pci_disable_device(ice
->pci
);
2221 static int snd_vt1724_dev_free(struct snd_device
*device
)
2223 struct snd_ice1712
*ice
= device
->device_data
;
2224 return snd_vt1724_free(ice
);
2227 static int __devinit
snd_vt1724_create(struct snd_card
*card
,
2228 struct pci_dev
*pci
,
2229 const char *modelname
,
2230 struct snd_ice1712
** r_ice1712
)
2232 struct snd_ice1712
*ice
;
2235 static struct snd_device_ops ops
= {
2236 .dev_free
= snd_vt1724_dev_free
,
2241 /* enable PCI device */
2242 if ((err
= pci_enable_device(pci
)) < 0)
2245 ice
= kzalloc(sizeof(*ice
), GFP_KERNEL
);
2247 pci_disable_device(pci
);
2251 spin_lock_init(&ice
->reg_lock
);
2252 mutex_init(&ice
->gpio_mutex
);
2253 mutex_init(&ice
->open_mutex
);
2254 mutex_init(&ice
->i2c_mutex
);
2255 ice
->gpio
.set_mask
= snd_vt1724_set_gpio_mask
;
2256 ice
->gpio
.set_dir
= snd_vt1724_set_gpio_dir
;
2257 ice
->gpio
.set_data
= snd_vt1724_set_gpio_data
;
2258 ice
->gpio
.get_data
= snd_vt1724_get_gpio_data
;
2262 pci_set_master(pci
);
2263 snd_vt1724_proc_init(ice
);
2264 synchronize_irq(pci
->irq
);
2266 if ((err
= pci_request_regions(pci
, "ICE1724")) < 0) {
2268 pci_disable_device(pci
);
2271 ice
->port
= pci_resource_start(pci
, 0);
2272 ice
->profi_port
= pci_resource_start(pci
, 1);
2274 if (request_irq(pci
->irq
, snd_vt1724_interrupt
,
2275 IRQF_SHARED
, "ICE1724", ice
)) {
2276 snd_printk(KERN_ERR
"unable to grab IRQ %d\n", pci
->irq
);
2277 snd_vt1724_free(ice
);
2281 ice
->irq
= pci
->irq
;
2283 snd_vt1724_chip_reset(ice
);
2284 if (snd_vt1724_read_eeprom(ice
, modelname
) < 0) {
2285 snd_vt1724_free(ice
);
2288 if (snd_vt1724_chip_init(ice
) < 0) {
2289 snd_vt1724_free(ice
);
2293 /* unmask used interrupts */
2294 mask
= VT1724_IRQ_MPU_RX
| VT1724_IRQ_MPU_TX
;
2295 outb(mask
, ICEREG1724(ice
, IRQMASK
));
2296 /* don't handle FIFO overrun/underruns (just yet),
2297 * since they cause machine lockups
2299 outb(VT1724_MULTI_FIFO_ERR
, ICEMT1724(ice
, DMA_INT_MASK
));
2301 if ((err
= snd_device_new(card
, SNDRV_DEV_LOWLEVEL
, ice
, &ops
)) < 0) {
2302 snd_vt1724_free(ice
);
2306 snd_card_set_dev(card
, &pci
->dev
);
2319 static int __devinit
snd_vt1724_probe(struct pci_dev
*pci
,
2320 const struct pci_device_id
*pci_id
)
2323 struct snd_card
*card
;
2324 struct snd_ice1712
*ice
;
2325 int pcm_dev
= 0, err
;
2326 struct snd_ice1712_card_info
* const *tbl
, *c
;
2328 if (dev
>= SNDRV_CARDS
)
2335 card
= snd_card_new(index
[dev
], id
[dev
], THIS_MODULE
, 0);
2339 strcpy(card
->driver
, "ICE1724");
2340 strcpy(card
->shortname
, "ICEnsemble ICE1724");
2342 if ((err
= snd_vt1724_create(card
, pci
, model
[dev
], &ice
)) < 0) {
2343 snd_card_free(card
);
2347 for (tbl
= card_tables
; *tbl
; tbl
++) {
2348 for (c
= *tbl
; c
->subvendor
; c
++) {
2349 if (c
->subvendor
== ice
->eeprom
.subvendor
) {
2350 strcpy(card
->shortname
, c
->name
);
2351 if (c
->driver
) /* specific driver? */
2352 strcpy(card
->driver
, c
->driver
);
2354 if ((err
= c
->chip_init(ice
)) < 0) {
2355 snd_card_free(card
);
2366 * VT1724 has separate DMAs for the analog and the SPDIF streams while
2367 * ICE1712 has only one for both (mixed up).
2369 * Confusingly the analog PCM is named "professional" here because it
2370 * was called so in ice1712 driver, and vt1724 driver is derived from
2373 ice
->pro_rate_default
= PRO_RATE_DEFAULT
;
2374 if (!ice
->is_spdif_master
)
2375 ice
->is_spdif_master
= stdclock_is_spdif_master
;
2377 ice
->get_rate
= stdclock_get_rate
;
2379 ice
->set_rate
= stdclock_set_rate
;
2381 ice
->set_mclk
= stdclock_set_mclk
;
2382 if (!ice
->set_spdif_clock
)
2383 ice
->set_spdif_clock
= stdclock_set_spdif_clock
;
2385 set_std_hw_rates(ice
);
2387 if ((err
= snd_vt1724_pcm_profi(ice
, pcm_dev
++)) < 0) {
2388 snd_card_free(card
);
2392 if ((err
= snd_vt1724_pcm_spdif(ice
, pcm_dev
++)) < 0) {
2393 snd_card_free(card
);
2397 if ((err
= snd_vt1724_pcm_indep(ice
, pcm_dev
++)) < 0) {
2398 snd_card_free(card
);
2402 if ((err
= snd_vt1724_ac97_mixer(ice
)) < 0) {
2403 snd_card_free(card
);
2407 if ((err
= snd_vt1724_build_controls(ice
)) < 0) {
2408 snd_card_free(card
);
2412 if (ice
->pcm
&& ice
->has_spdif
) { /* has SPDIF I/O */
2413 if ((err
= snd_vt1724_spdif_build_controls(ice
)) < 0) {
2414 snd_card_free(card
);
2419 if (c
->build_controls
) {
2420 if ((err
= c
->build_controls(ice
)) < 0) {
2421 snd_card_free(card
);
2426 if (! c
->no_mpu401
) {
2427 if (ice
->eeprom
.data
[ICE_EEP2_SYSCONF
] & VT1724_CFG_MPU401
) {
2428 struct snd_mpu401
*mpu
;
2429 if ((err
= snd_mpu401_uart_new(card
, 0, MPU401_HW_ICE1712
,
2430 ICEREG1724(ice
, MPU_CTRL
),
2431 (MPU401_INFO_INTEGRATED
|
2432 MPU401_INFO_NO_ACK
|
2433 MPU401_INFO_TX_IRQ
),
2435 &ice
->rmidi
[0])) < 0) {
2436 snd_card_free(card
);
2439 mpu
= ice
->rmidi
[0]->private_data
;
2440 mpu
->read
= snd_vt1724_mpu401_read
;
2441 mpu
->write
= snd_vt1724_mpu401_write
;
2442 /* unmask MPU RX/TX irqs */
2443 outb(inb(ICEREG1724(ice
, IRQMASK
)) &
2444 ~(VT1724_IRQ_MPU_RX
| VT1724_IRQ_MPU_TX
),
2445 ICEREG1724(ice
, IRQMASK
));
2446 /* set watermarks */
2447 outb(VT1724_MPU_RX_FIFO
| 0x1,
2448 ICEREG1724(ice
, MPU_FIFO_WM
));
2449 outb(0x1, ICEREG1724(ice
, MPU_FIFO_WM
));
2453 sprintf(card
->longname
, "%s at 0x%lx, irq %i",
2454 card
->shortname
, ice
->port
, ice
->irq
);
2456 if ((err
= snd_card_register(card
)) < 0) {
2457 snd_card_free(card
);
2460 pci_set_drvdata(pci
, card
);
2465 static void __devexit
snd_vt1724_remove(struct pci_dev
*pci
)
2467 snd_card_free(pci_get_drvdata(pci
));
2468 pci_set_drvdata(pci
, NULL
);
2471 static struct pci_driver driver
= {
2473 .id_table
= snd_vt1724_ids
,
2474 .probe
= snd_vt1724_probe
,
2475 .remove
= __devexit_p(snd_vt1724_remove
),
2478 static int __init
alsa_card_ice1724_init(void)
2480 return pci_register_driver(&driver
);
2483 static void __exit
alsa_card_ice1724_exit(void)
2485 pci_unregister_driver(&driver
);
2488 module_init(alsa_card_ice1724_init
)
2489 module_exit(alsa_card_ice1724_exit
)