2 * Driver for Digigram VX soundcards
6 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
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.
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.
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
23 #include <sound/driver.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/interrupt.h>
27 #include <linux/init.h>
28 #include <linux/device.h>
29 #include <linux/firmware.h>
30 #include <sound/core.h>
31 #include <sound/pcm.h>
32 #include <sound/asoundef.h>
33 #include <sound/info.h>
35 #include <sound/vx_core.h>
38 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
39 MODULE_DESCRIPTION("Common routines for Digigram VX drivers");
40 MODULE_LICENSE("GPL");
44 * snd_vx_delay - delay for the specified time
45 * @xmsec: the time to delay in msec
47 void snd_vx_delay(vx_core_t
*chip
, int xmsec
)
49 if (! in_interrupt() && xmsec
>= 1000 / HZ
)
56 * vx_check_reg_bit - wait for the specified bit is set/reset on a register
57 * @reg: register to check
59 * @bit: resultant bit to be checked
60 * @time: time-out of loop in msec
62 * returns zero if a bit matches, or a negative error code.
64 int snd_vx_check_reg_bit(vx_core_t
*chip
, int reg
, int mask
, int bit
, int time
)
66 unsigned long end_time
= jiffies
+ (time
* HZ
+ 999) / 1000;
67 #ifdef CONFIG_SND_DEBUG
68 static char *reg_names
[VX_REG_MAX
] = {
69 "ICR", "CVR", "ISR", "IVR", "RXH", "RXM", "RXL",
70 "DMA", "CDSP", "RFREQ", "RUER/V2", "DATA", "MEMIRQ",
71 "ACQ", "BIT0", "BIT1", "MIC0", "MIC1", "MIC2",
72 "MIC3", "INTCSR", "CNTRL", "GPIOC",
73 "LOFREQ", "HIFREQ", "CSUER", "RUER"
77 if ((snd_vx_inb(chip
, reg
) & mask
) == bit
)
79 //snd_vx_delay(chip, 10);
80 } while (time_after_eq(end_time
, jiffies
));
81 snd_printd(KERN_DEBUG
"vx_check_reg_bit: timeout, reg=%s, mask=0x%x, val=0x%x\n", reg_names
[reg
], mask
, snd_vx_inb(chip
, reg
));
86 * vx_send_irq_dsp - set command irq bit
87 * @num: the requested IRQ type, IRQ_XXX
89 * this triggers the specified IRQ request
90 * returns 0 if successful, or a negative error code.
93 static int vx_send_irq_dsp(vx_core_t
*chip
, int num
)
98 if (snd_vx_check_reg_bit(chip
, VX_CVR
, CVR_HC
, 0, 200) < 0)
102 if (vx_has_new_dsp(chip
))
103 nirq
+= VXP_IRQ_OFFSET
;
104 vx_outb(chip
, CVR
, (nirq
>> 1) | CVR_HC
);
110 * vx_reset_chk - reset CHK bit on ISR
112 * returns 0 if successful, or a negative error code.
114 static int vx_reset_chk(vx_core_t
*chip
)
117 if (vx_send_irq_dsp(chip
, IRQ_RESET_CHK
) < 0)
119 /* Wait until CHK = 0 */
120 if (vx_check_isr(chip
, ISR_CHK
, 0, 200) < 0)
126 * vx_transfer_end - terminate message transfer
127 * @cmd: IRQ message to send (IRQ_MESS_XXX_END)
129 * returns 0 if successful, or a negative error code.
130 * the error code can be VX-specific, retrieved via vx_get_error().
131 * NB: call with spinlock held!
133 static int vx_transfer_end(vx_core_t
*chip
, int cmd
)
137 if ((err
= vx_reset_chk(chip
)) < 0)
140 /* irq MESS_READ/WRITE_END */
141 if ((err
= vx_send_irq_dsp(chip
, cmd
)) < 0)
145 if ((err
= vx_wait_isr_bit(chip
, ISR_CHK
)) < 0)
148 /* If error, Read RX */
149 if ((err
= vx_inb(chip
, ISR
)) & ISR_ERR
) {
150 if ((err
= vx_wait_for_rx_full(chip
)) < 0) {
151 snd_printd(KERN_DEBUG
"transfer_end: error in rx_full\n");
154 err
= vx_inb(chip
, RXH
) << 16;
155 err
|= vx_inb(chip
, RXM
) << 8;
156 err
|= vx_inb(chip
, RXL
);
157 snd_printd(KERN_DEBUG
"transfer_end: error = 0x%x\n", err
);
158 return -(VX_ERR_MASK
| err
);
164 * vx_read_status - return the status rmh
165 * @rmh: rmh record to store the status
167 * returns 0 if successful, or a negative error code.
168 * the error code can be VX-specific, retrieved via vx_get_error().
169 * NB: call with spinlock held!
171 static int vx_read_status(vx_core_t
*chip
, struct vx_rmh
*rmh
)
173 int i
, err
, val
, size
;
175 /* no read necessary? */
176 if (rmh
->DspStat
== RMH_SSIZE_FIXED
&& rmh
->LgStat
== 0)
179 /* Wait for RX full (with timeout protection)
180 * The first word of status is in RX
182 err
= vx_wait_for_rx_full(chip
);
187 val
= vx_inb(chip
, RXH
) << 16;
188 val
|= vx_inb(chip
, RXM
) << 8;
189 val
|= vx_inb(chip
, RXL
);
191 /* If status given by DSP, let's decode its size */
192 switch (rmh
->DspStat
) {
195 rmh
->Stat
[0] = val
& 0xffff00;
196 rmh
->LgStat
= size
+ 1;
199 /* Let's count the arg numbers from a mask */
207 rmh
->LgStat
= size
+ 1;
210 /* else retrieve the status length given by the driver */
212 rmh
->Stat
[0] = val
; /* Val is the status 1st word */
213 size
--; /* hence adjust remaining length */
219 snd_assert(size
<= SIZE_MAX_STATUS
, return -EINVAL
);
221 for (i
= 1; i
<= size
; i
++) {
222 /* trigger an irq MESS_WRITE_NEXT */
223 err
= vx_send_irq_dsp(chip
, IRQ_MESS_WRITE_NEXT
);
226 /* Wait for RX full (with timeout protection) */
227 err
= vx_wait_for_rx_full(chip
);
230 rmh
->Stat
[i
] = vx_inb(chip
, RXH
) << 16;
231 rmh
->Stat
[i
] |= vx_inb(chip
, RXM
) << 8;
232 rmh
->Stat
[i
] |= vx_inb(chip
, RXL
);
235 return vx_transfer_end(chip
, IRQ_MESS_WRITE_END
);
239 #define MASK_MORE_THAN_1_WORD_COMMAND 0x00008000
240 #define MASK_1_WORD_COMMAND 0x00ff7fff
243 * vx_send_msg_nolock - send a DSP message and read back the status
244 * @rmh: the rmh record to send and receive
246 * returns 0 if successful, or a negative error code.
247 * the error code can be VX-specific, retrieved via vx_get_error().
249 * this function doesn't call spinlock at all.
251 int vx_send_msg_nolock(vx_core_t
*chip
, struct vx_rmh
*rmh
)
255 if (chip
->chip_status
& VX_STAT_IS_STALE
)
258 if ((err
= vx_reset_chk(chip
)) < 0) {
259 snd_printd(KERN_DEBUG
"vx_send_msg: vx_reset_chk error\n");
264 printk(KERN_DEBUG
"rmh: cmd = 0x%06x, length = %d, stype = %d\n",
265 rmh
->Cmd
[0], rmh
->LgCmd
, rmh
->DspStat
);
266 if (rmh
->LgCmd
> 1) {
267 printk(KERN_DEBUG
" ");
268 for (i
= 1; i
< rmh
->LgCmd
; i
++)
269 printk("0x%06x ", rmh
->Cmd
[i
]);
273 /* Check bit M is set according to length of the command */
275 rmh
->Cmd
[0] |= MASK_MORE_THAN_1_WORD_COMMAND
;
277 rmh
->Cmd
[0] &= MASK_1_WORD_COMMAND
;
279 /* Wait for TX empty */
280 if ((err
= vx_wait_isr_bit(chip
, ISR_TX_EMPTY
)) < 0) {
281 snd_printd(KERN_DEBUG
"vx_send_msg: wait tx empty error\n");
286 vx_outb(chip
, TXH
, (rmh
->Cmd
[0] >> 16) & 0xff);
287 vx_outb(chip
, TXM
, (rmh
->Cmd
[0] >> 8) & 0xff);
288 vx_outb(chip
, TXL
, rmh
->Cmd
[0] & 0xff);
290 /* Trigger irq MESSAGE */
291 if ((err
= vx_send_irq_dsp(chip
, IRQ_MESSAGE
)) < 0) {
292 snd_printd(KERN_DEBUG
"vx_send_msg: send IRQ_MESSAGE error\n");
296 /* Wait for CHK = 1 */
297 if ((err
= vx_wait_isr_bit(chip
, ISR_CHK
)) < 0)
300 /* If error, get error value from RX */
301 if (vx_inb(chip
, ISR
) & ISR_ERR
) {
302 if ((err
= vx_wait_for_rx_full(chip
)) < 0) {
303 snd_printd(KERN_DEBUG
"vx_send_msg: rx_full read error\n");
306 err
= vx_inb(chip
, RXH
) << 16;
307 err
|= vx_inb(chip
, RXM
) << 8;
308 err
|= vx_inb(chip
, RXL
);
309 snd_printd(KERN_DEBUG
"msg got error = 0x%x at cmd[0]\n", err
);
310 err
= -(VX_ERR_MASK
| err
);
314 /* Send the other words */
315 if (rmh
->LgCmd
> 1) {
316 for (i
= 1; i
< rmh
->LgCmd
; i
++) {
317 /* Wait for TX ready */
318 if ((err
= vx_wait_isr_bit(chip
, ISR_TX_READY
)) < 0) {
319 snd_printd(KERN_DEBUG
"vx_send_msg: tx_ready error\n");
324 vx_outb(chip
, TXH
, (rmh
->Cmd
[i
] >> 16) & 0xff);
325 vx_outb(chip
, TXM
, (rmh
->Cmd
[i
] >> 8) & 0xff);
326 vx_outb(chip
, TXL
, rmh
->Cmd
[i
] & 0xff);
328 /* Trigger irq MESS_READ_NEXT */
329 if ((err
= vx_send_irq_dsp(chip
, IRQ_MESS_READ_NEXT
)) < 0) {
330 snd_printd(KERN_DEBUG
"vx_send_msg: IRQ_READ_NEXT error\n");
334 /* Wait for TX empty */
335 if ((err
= vx_wait_isr_bit(chip
, ISR_TX_READY
)) < 0) {
336 snd_printd(KERN_DEBUG
"vx_send_msg: TX_READY error\n");
339 /* End of transfer */
340 err
= vx_transfer_end(chip
, IRQ_MESS_READ_END
);
345 return vx_read_status(chip
, rmh
);
350 * vx_send_msg - send a DSP message with spinlock
351 * @rmh: the rmh record to send and receive
353 * returns 0 if successful, or a negative error code.
354 * see vx_send_msg_nolock().
356 int vx_send_msg(vx_core_t
*chip
, struct vx_rmh
*rmh
)
361 spin_lock_irqsave(&chip
->lock
, flags
);
362 err
= vx_send_msg_nolock(chip
, rmh
);
363 spin_unlock_irqrestore(&chip
->lock
, flags
);
369 * vx_send_rih_nolock - send an RIH to xilinx
370 * @cmd: the command to send
372 * returns 0 if successful, or a negative error code.
373 * the error code can be VX-specific, retrieved via vx_get_error().
375 * this function doesn't call spinlock at all.
377 * unlike RMH, no command is sent to DSP.
379 int vx_send_rih_nolock(vx_core_t
*chip
, int cmd
)
383 if (chip
->chip_status
& VX_STAT_IS_STALE
)
387 printk(KERN_DEBUG
"send_rih: cmd = 0x%x\n", cmd
);
389 if ((err
= vx_reset_chk(chip
)) < 0)
392 if ((err
= vx_send_irq_dsp(chip
, cmd
)) < 0)
395 if ((err
= vx_wait_isr_bit(chip
, ISR_CHK
)) < 0)
397 /* If error, read RX */
398 if (vx_inb(chip
, ISR
) & ISR_ERR
) {
399 if ((err
= vx_wait_for_rx_full(chip
)) < 0)
401 err
= vx_inb(chip
, RXH
) << 16;
402 err
|= vx_inb(chip
, RXM
) << 8;
403 err
|= vx_inb(chip
, RXL
);
404 return -(VX_ERR_MASK
| err
);
411 * vx_send_rih - send an RIH with spinlock
412 * @cmd: the command to send
414 * see vx_send_rih_nolock().
416 int vx_send_rih(vx_core_t
*chip
, int cmd
)
421 spin_lock_irqsave(&chip
->lock
, flags
);
422 err
= vx_send_rih_nolock(chip
, cmd
);
423 spin_unlock_irqrestore(&chip
->lock
, flags
);
427 #define END_OF_RESET_WAIT_TIME 500 /* us */
430 * snd_vx_boot_xilinx - boot up the xilinx interface
431 * @boot: the boot record to load
433 int snd_vx_load_boot_image(vx_core_t
*chip
, const struct firmware
*boot
)
436 int no_fillup
= vx_has_new_dsp(chip
);
438 /* check the length of boot image */
439 snd_assert(boot
->size
> 0, return -EINVAL
);
440 snd_assert(boot
->size
% 3 == 0, return -EINVAL
);
443 /* more strict check */
444 unsigned int c
= ((u32
)boot
->data
[0] << 16) | ((u32
)boot
->data
[1] << 8) | boot
->data
[2];
445 snd_assert(boot
->size
== (c
+ 2) * 3, return -EINVAL
);
452 udelay(END_OF_RESET_WAIT_TIME
); /* another wait? */
454 /* download boot strap */
455 for (i
= 0; i
< 0x600; i
+= 3) {
456 if (i
>= boot
->size
) {
459 if (vx_wait_isr_bit(chip
, ISR_TX_EMPTY
) < 0) {
460 snd_printk(KERN_ERR
"dsp boot failed at %d\n", i
);
463 vx_outb(chip
, TXH
, 0);
464 vx_outb(chip
, TXM
, 0);
465 vx_outb(chip
, TXL
, 0);
467 unsigned char *image
= boot
->data
+ i
;
468 if (vx_wait_isr_bit(chip
, ISR_TX_EMPTY
) < 0) {
469 snd_printk(KERN_ERR
"dsp boot failed at %d\n", i
);
472 vx_outb(chip
, TXH
, image
[0]);
473 vx_outb(chip
, TXM
, image
[1]);
474 vx_outb(chip
, TXL
, image
[2]);
481 * vx_test_irq_src - query the source of interrupts
483 * called from irq handler only
485 static int vx_test_irq_src(vx_core_t
*chip
, unsigned int *ret
)
489 vx_init_rmh(&chip
->irq_rmh
, CMD_TEST_IT
);
490 spin_lock(&chip
->lock
);
491 err
= vx_send_msg_nolock(chip
, &chip
->irq_rmh
);
495 *ret
= chip
->irq_rmh
.Stat
[0];
496 spin_unlock(&chip
->lock
);
502 * vx_interrupt - soft irq handler
504 static void vx_interrupt(unsigned long private_data
)
506 vx_core_t
*chip
= (vx_core_t
*) private_data
;
509 if (chip
->chip_status
& VX_STAT_IS_STALE
)
512 if (vx_test_irq_src(chip
, &events
) < 0)
516 if (events
& 0x000800)
517 printk(KERN_ERR
"DSP Stream underrun ! IRQ events = 0x%x\n", events
);
519 // printk(KERN_DEBUG "IRQ events = 0x%x\n", events);
521 /* We must prevent any application using this DSP
522 * and block any further request until the application
523 * either unregisters or reloads the DSP
525 if (events
& FATAL_DSP_ERROR
) {
526 snd_printk(KERN_ERR
"vx_core: fatal DSP error!!\n");
530 /* The start on time code conditions are filled (ie the time code
531 * received by the board is equal to one of those given to it).
533 if (events
& TIME_CODE_EVENT_PENDING
)
534 ; /* so far, nothing to do yet */
536 /* The frequency has changed on the board (UER mode). */
537 if (events
& FREQUENCY_CHANGE_EVENT_PENDING
)
538 vx_change_frequency(chip
);
540 /* update the pcm streams */
541 vx_pcm_update_intr(chip
, events
);
546 * snd_vx_irq_handler - interrupt handler
548 irqreturn_t
snd_vx_irq_handler(int irq
, void *dev
, struct pt_regs
*regs
)
550 vx_core_t
*chip
= dev
;
552 if (! (chip
->chip_status
& VX_STAT_CHIP_INIT
) ||
553 (chip
->chip_status
& VX_STAT_IS_STALE
))
555 if (! vx_test_and_ack(chip
))
556 tasklet_hi_schedule(&chip
->tq
);
563 static void vx_reset_board(vx_core_t
*chip
, int cold_reset
)
565 snd_assert(chip
->ops
->reset_board
, return);
567 /* current source, later sync'ed with target */
568 chip
->audio_source
= VX_AUDIO_SRC_LINE
;
570 chip
->audio_source_target
= chip
->audio_source
;
571 chip
->clock_source
= INTERNAL_QUARTZ
;
572 chip
->clock_mode
= VX_CLOCK_MODE_AUTO
;
574 chip
->uer_detected
= VX_UER_MODE_NOT_PRESENT
;
575 chip
->uer_bits
= SNDRV_PCM_DEFAULT_CON_SPDIF
;
578 chip
->ops
->reset_board(chip
, cold_reset
);
580 vx_reset_codec(chip
, cold_reset
);
582 vx_set_internal_clock(chip
, chip
->freq
);
587 if (vx_is_pcmcia(chip
)) {
588 /* Acknowledge any pending IRQ and reset the MEMIRQ flag. */
589 vx_test_and_ack(chip
);
590 vx_validate_irq(chip
, 1);
594 vx_set_iec958_status(chip
, chip
->uer_bits
);
602 static void vx_proc_read(snd_info_entry_t
*entry
, snd_info_buffer_t
*buffer
)
604 vx_core_t
*chip
= entry
->private_data
;
605 static char *audio_src_vxp
[] = { "Line", "Mic", "Digital" };
606 static char *audio_src_vx2
[] = { "Analog", "Analog", "Digital" };
607 static char *clock_mode
[] = { "Auto", "Internal", "External" };
608 static char *clock_src
[] = { "Internal", "External" };
609 static char *uer_type
[] = { "Consumer", "Professional", "Not Present" };
611 snd_iprintf(buffer
, "%s\n", chip
->card
->longname
);
612 snd_iprintf(buffer
, "Xilinx Firmware: %s\n",
613 chip
->chip_status
& VX_STAT_XILINX_LOADED
? "Loaded" : "No");
614 snd_iprintf(buffer
, "Device Initialized: %s\n",
615 chip
->chip_status
& VX_STAT_DEVICE_INIT
? "Yes" : "No");
616 snd_iprintf(buffer
, "DSP audio info:");
617 if (chip
->audio_info
& VX_AUDIO_INFO_REAL_TIME
)
618 snd_iprintf(buffer
, " realtime");
619 if (chip
->audio_info
& VX_AUDIO_INFO_OFFLINE
)
620 snd_iprintf(buffer
, " offline");
621 if (chip
->audio_info
& VX_AUDIO_INFO_MPEG1
)
622 snd_iprintf(buffer
, " mpeg1");
623 if (chip
->audio_info
& VX_AUDIO_INFO_MPEG2
)
624 snd_iprintf(buffer
, " mpeg2");
625 if (chip
->audio_info
& VX_AUDIO_INFO_LINEAR_8
)
626 snd_iprintf(buffer
, " linear8");
627 if (chip
->audio_info
& VX_AUDIO_INFO_LINEAR_16
)
628 snd_iprintf(buffer
, " linear16");
629 if (chip
->audio_info
& VX_AUDIO_INFO_LINEAR_24
)
630 snd_iprintf(buffer
, " linear24");
631 snd_iprintf(buffer
, "\n");
632 snd_iprintf(buffer
, "Input Source: %s\n", vx_is_pcmcia(chip
) ?
633 audio_src_vxp
[chip
->audio_source
] :
634 audio_src_vx2
[chip
->audio_source
]);
635 snd_iprintf(buffer
, "Clock Mode: %s\n", clock_mode
[chip
->clock_mode
]);
636 snd_iprintf(buffer
, "Clock Source: %s\n", clock_src
[chip
->clock_source
]);
637 snd_iprintf(buffer
, "Frequency: %d\n", chip
->freq
);
638 snd_iprintf(buffer
, "Detected Frequency: %d\n", chip
->freq_detected
);
639 snd_iprintf(buffer
, "Detected UER type: %s\n", uer_type
[chip
->uer_detected
]);
640 snd_iprintf(buffer
, "Min/Max/Cur IBL: %d/%d/%d (granularity=%d)\n",
641 chip
->ibl
.min_size
, chip
->ibl
.max_size
, chip
->ibl
.size
,
642 chip
->ibl
.granularity
);
645 static void vx_proc_init(vx_core_t
*chip
)
647 snd_info_entry_t
*entry
;
649 if (! snd_card_proc_new(chip
->card
, "vx-status", &entry
))
650 snd_info_set_text_ops(entry
, chip
, 1024, vx_proc_read
);
655 * snd_vx_dsp_boot - load the DSP boot
657 int snd_vx_dsp_boot(vx_core_t
*chip
, const struct firmware
*boot
)
660 int cold_reset
= !(chip
->chip_status
& VX_STAT_DEVICE_INIT
);
662 vx_reset_board(chip
, cold_reset
);
663 vx_validate_irq(chip
, 0);
665 if ((err
= snd_vx_load_boot_image(chip
, boot
)) < 0)
667 snd_vx_delay(chip
, 10);
673 * snd_vx_dsp_load - load the DSP image
675 int snd_vx_dsp_load(vx_core_t
*chip
, const struct firmware
*dsp
)
679 unsigned int csum
= 0;
680 unsigned char *image
, *cptr
;
682 snd_assert(dsp
->size
% 3 == 0, return -EINVAL
);
684 vx_toggle_dac_mute(chip
, 1);
686 /* Transfert data buffer from PC to DSP */
687 for (i
= 0; i
< dsp
->size
; i
+= 3) {
688 image
= dsp
->data
+ i
;
689 /* Wait DSP ready for a new read */
690 if ((err
= vx_wait_isr_bit(chip
, ISR_TX_EMPTY
)) < 0) {
691 printk("dsp loading error at position %d\n", i
);
696 csum
= (csum
>> 24) | (csum
<< 8);
697 vx_outb(chip
, TXH
, *cptr
++);
699 csum
= (csum
>> 24) | (csum
<< 8);
700 vx_outb(chip
, TXM
, *cptr
++);
702 csum
= (csum
>> 24) | (csum
<< 8);
703 vx_outb(chip
, TXL
, *cptr
++);
705 snd_printdd(KERN_DEBUG
"checksum = 0x%08x\n", csum
);
707 snd_vx_delay(chip
, 200);
709 if ((err
= vx_wait_isr_bit(chip
, ISR_CHK
)) < 0)
712 vx_toggle_dac_mute(chip
, 0);
714 vx_test_and_ack(chip
);
715 vx_validate_irq(chip
, 1);
724 static int snd_vx_suspend(snd_card_t
*card
, pm_message_t state
)
726 vx_core_t
*chip
= card
->pm_private_data
;
729 snd_assert(chip
, return -EINVAL
);
731 chip
->chip_status
|= VX_STAT_IN_SUSPEND
;
732 for (i
= 0; i
< chip
->hw
->num_codecs
; i
++)
733 snd_pcm_suspend_all(chip
->pcm
[i
]);
741 static int snd_vx_resume(snd_card_t
*card
)
743 vx_core_t
*chip
= card
->pm_private_data
;
746 snd_assert(chip
, return -EINVAL
);
748 chip
->chip_status
&= ~VX_STAT_CHIP_INIT
;
750 for (i
= 0; i
< 4; i
++) {
751 if (! chip
->firmware
[i
])
753 err
= chip
->ops
->load_dsp(chip
, i
, chip
->firmware
[i
]);
755 snd_printk(KERN_ERR
"vx: firmware resume error at DSP %d\n", i
);
760 chip
->chip_status
|= VX_STAT_CHIP_INIT
;
761 chip
->chip_status
&= ~VX_STAT_IN_SUSPEND
;
769 * snd_vx_create - constructor for vx_core_t
770 * @hw: hardware specific record
772 * this function allocates the instance and prepare for the hardware
775 * return the instance pointer if successful, NULL in error.
777 vx_core_t
*snd_vx_create(snd_card_t
*card
, struct snd_vx_hardware
*hw
,
778 struct snd_vx_ops
*ops
,
783 snd_assert(card
&& hw
&& ops
, return NULL
);
785 chip
= kcalloc(1, sizeof(*chip
) + extra_size
, GFP_KERNEL
);
787 snd_printk(KERN_ERR
"vx_core: no memory\n");
790 spin_lock_init(&chip
->lock
);
791 spin_lock_init(&chip
->irq_lock
);
794 chip
->type
= hw
->type
;
796 tasklet_init(&chip
->tq
, vx_interrupt
, (unsigned long)chip
);
797 init_MUTEX(&chip
->mixer_mutex
);
800 card
->private_data
= chip
;
801 strcpy(card
->driver
, hw
->name
);
802 sprintf(card
->shortname
, "Digigram %s", hw
->name
);
804 snd_card_set_pm_callback(card
, snd_vx_suspend
, snd_vx_resume
, chip
);
814 static int __init
alsa_vx_core_init(void)
819 static void __exit
alsa_vx_core_exit(void)
823 module_init(alsa_vx_core_init
)
824 module_exit(alsa_vx_core_exit
)
829 EXPORT_SYMBOL(snd_vx_check_reg_bit
);
830 EXPORT_SYMBOL(snd_vx_create
);
831 EXPORT_SYMBOL(snd_vx_setup_firmware
);
832 EXPORT_SYMBOL(snd_vx_free_firmware
);
833 EXPORT_SYMBOL(snd_vx_irq_handler
);
834 EXPORT_SYMBOL(snd_vx_delay
);
835 EXPORT_SYMBOL(snd_vx_dsp_boot
);
836 EXPORT_SYMBOL(snd_vx_dsp_load
);
837 EXPORT_SYMBOL(snd_vx_load_boot_image
);