24 #include <linux/slab.h>
27 #include <linux/device.h>
29 #include <linux/module.h>
54 unsigned long end_time =
jiffies + (time *
HZ + 999) / 1000;
55 #ifdef CONFIG_SND_DEBUG
57 "ICR",
"CVR",
"ISR",
"IVR",
"RXH",
"RXM",
"RXL",
58 "DMA",
"CDSP",
"RFREQ",
"RUER/V2",
"DATA",
"MEMIRQ",
59 "ACQ",
"BIT0",
"BIT1",
"MIC0",
"MIC1",
"MIC2",
60 "MIC3",
"INTCSR",
"CNTRL",
"GPIOC",
61 "LOFREQ",
"HIFREQ",
"CSUER",
"RUER"
65 if ((snd_vx_inb(chip, reg) & mask) ==
bit)
69 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));
83 static int vx_send_irq_dsp(
struct vx_core *
chip,
int num)
104 static int vx_reset_chk(
struct vx_core *chip)
123 static int vx_transfer_end(
struct vx_core *chip,
int cmd)
127 if ((err = vx_reset_chk(chip)) < 0)
131 if ((err = vx_send_irq_dsp(chip, cmd)) < 0)
144 err =
vx_inb(chip, RXH) << 16;
145 err |=
vx_inb(chip, RXM) << 8;
161 static int vx_read_status(
struct vx_core *chip,
struct vx_rmh *rmh)
177 val =
vx_inb(chip, RXH) << 16;
178 val |=
vx_inb(chip, RXM) << 8;
185 rmh->
Stat[0] = val & 0xffff00;
212 for (i = 1; i <=
size; i++) {
230 #define MASK_MORE_THAN_1_WORD_COMMAND 0x00008000
231 #define MASK_1_WORD_COMMAND 0x00ff7fff
249 if ((err = vx_reset_chk(chip)) < 0) {
257 if (rmh->
LgCmd > 1) {
259 for (i = 1; i < rmh->
LgCmd; i++)
277 vx_outb(chip, TXH, (rmh->
Cmd[0] >> 16) & 0xff);
278 vx_outb(chip, TXM, (rmh->
Cmd[0] >> 8) & 0xff);
282 if ((err = vx_send_irq_dsp(chip,
IRQ_MESSAGE)) < 0) {
297 err =
vx_inb(chip, RXH) << 16;
298 err |=
vx_inb(chip, RXM) << 8;
306 if (rmh->
LgCmd > 1) {
307 for (i = 1; i < rmh->
LgCmd; i++) {
315 vx_outb(chip, TXH, (rmh->
Cmd[i] >> 16) & 0xff);
316 vx_outb(chip, TXM, (rmh->
Cmd[i] >> 8) & 0xff);
336 return vx_read_status(chip, rmh);
354 spin_unlock_irqrestore(&chip->
lock, flags);
380 if ((err = vx_reset_chk(chip)) < 0)
383 if ((err = vx_send_irq_dsp(chip, cmd)) < 0)
392 err =
vx_inb(chip, RXH) << 16;
393 err |=
vx_inb(chip, RXM) << 8;
414 spin_unlock_irqrestore(&chip->
lock, flags);
418 #define END_OF_RESET_WAIT_TIME 500
438 if (boot->
size != (c + 2) * 3)
449 for (i = 0; i < 0x600; i += 3) {
450 if (i >= boot->
size) {
481 static int vx_test_irq_src(
struct vx_core *chip,
unsigned int *
ret)
486 spin_lock(&chip->
lock);
492 spin_unlock(&chip->
lock);
508 if (vx_test_irq_src(chip, &events) < 0)
512 if (events & 0x000800)
513 printk(
KERN_ERR "DSP Stream underrun ! IRQ events = 0x%x\n", events);
551 if (! vx_test_and_ack(chip))
552 tasklet_schedule(&chip->
tq);
560 static void vx_reset_board(
struct vx_core *chip,
int cold_reset)
576 chip->
ops->reset_board(chip, cold_reset);
587 vx_test_and_ack(chip);
588 vx_validate_irq(chip, 1);
603 static char *audio_src_vxp[] = {
"Line",
"Mic",
"Digital" };
604 static char *audio_src_vx2[] = {
"Analog",
"Analog",
"Digital" };
605 static char *
clock_mode[] = {
"Auto",
"Internal",
"External" };
606 static char *clock_src[] = {
"Internal",
"External" };
607 static char *uer_type[] = {
"Consumer",
"Professional",
"Not Present" };
609 snd_iprintf(buffer,
"%s\n", chip->
card->longname);
610 snd_iprintf(buffer,
"Xilinx Firmware: %s\n",
612 snd_iprintf(buffer,
"Device Initialized: %s\n",
614 snd_iprintf(buffer,
"DSP audio info:");
616 snd_iprintf(buffer,
" realtime");
618 snd_iprintf(buffer,
" offline");
620 snd_iprintf(buffer,
" mpeg1");
622 snd_iprintf(buffer,
" mpeg2");
624 snd_iprintf(buffer,
" linear8");
626 snd_iprintf(buffer,
" linear16");
628 snd_iprintf(buffer,
" linear24");
629 snd_iprintf(buffer,
"\n");
630 snd_iprintf(buffer,
"Input Source: %s\n",
vx_is_pcmcia(chip) ?
633 snd_iprintf(buffer,
"Clock Mode: %s\n", clock_mode[chip->
clock_mode]);
634 snd_iprintf(buffer,
"Clock Source: %s\n", clock_src[chip->
clock_source]);
635 snd_iprintf(buffer,
"Frequency: %d\n", chip->
freq);
636 snd_iprintf(buffer,
"Detected Frequency: %d\n", chip->
freq_detected);
637 snd_iprintf(buffer,
"Detected UER type: %s\n", uer_type[chip->
uer_detected]);
638 snd_iprintf(buffer,
"Min/Max/Cur IBL: %d/%d/%d (granularity=%d)\n",
639 chip->
ibl.min_size, chip->
ibl.max_size, chip->
ibl.size,
640 chip->
ibl.granularity);
643 static void vx_proc_init(
struct vx_core *chip)
647 if (! snd_card_proc_new(chip->
card,
"vx-status", &entry))
648 snd_info_set_text_ops(entry, chip, vx_proc_read);
660 vx_reset_board(chip, cold_reset);
661 vx_validate_irq(chip, 0);
679 unsigned int csum = 0;
680 const unsigned char *
image, *cptr;
688 for (i = 0; i < dsp->
size; i += 3) {
689 image = dsp->
data +
i;
693 "dsp loading error at position %d\n", i);
698 csum = (csum >> 24) | (csum << 8);
701 csum = (csum >> 24) | (csum << 8);
704 csum = (csum >> 24) | (csum << 8);
716 vx_test_and_ack(chip);
717 vx_validate_irq(chip, 1);
734 for (i = 0; i < chip->
hw->num_codecs; i++)
735 snd_pcm_suspend_all(chip->
pcm[i]);
751 for (i = 0; i < 4; i++) {
754 err = chip->
ops->load_dsp(chip, i, chip->
firmware[i]);
789 chip = kzalloc(
sizeof(*chip) + extra_size,
GFP_KERNEL);
818 static int __init alsa_vx_core_init(
void)
823 static void __exit alsa_vx_core_exit(
void)