Lines Matching refs:devc
86 int sb_dsp_command(sb_devc * devc, unsigned char val) in sb_dsp_command() argument
113 int sb_dsp_get_byte(sb_devc * devc) in sb_dsp_get_byte() argument
125 static void sb_intr (sb_devc *devc) in sb_intr() argument
130 if (devc->model == MDL_SB16) in sb_intr()
132 src = sb_getmixer(devc, IRQ_STAT); /* Interrupt source register */ in sb_intr()
135 if(devc->midi_irq_cookie) in sb_intr()
136 uart401intr(devc->irq, devc->midi_irq_cookie); in sb_intr()
141 if (devc->intr_active && (!devc->fullduplex || (src & 0x01))) in sb_intr()
143 switch (devc->irq_mode) in sb_intr()
146 DMAbuf_outputintr(devc->dev, 1); in sb_intr()
150 DMAbuf_inputintr(devc->dev); in sb_intr()
157 sb_midi_interrupt(devc); in sb_intr()
165 else if (devc->intr_active_16 && (src & 0x02)) in sb_intr()
167 switch (devc->irq_mode_16) in sb_intr()
170 DMAbuf_outputintr(devc->dev, 1); in sb_intr()
174 DMAbuf_inputintr(devc->dev); in sb_intr()
192 if (devc->model == MDL_SB16 && src & 0x02) in sb_intr()
196 static void pci_intr(sb_devc *devc) in pci_intr() argument
198 int src = inb(devc->pcibase+0x1A); in pci_intr()
201 sb_intr(devc); in pci_intr()
206 sb_devc *devc = dev_id; in sbintr() local
208 devc->irq_ok = 1; in sbintr()
210 switch (devc->model) { in sbintr()
212 pci_intr (devc); in sbintr()
216 ess_intr (devc); in sbintr()
219 sb_intr (devc); in sbintr()
225 int sb_dsp_reset(sb_devc * devc) in sb_dsp_reset() argument
231 if (devc->model == MDL_ESS) return ess_dsp_reset (devc); in sb_dsp_reset()
254 static void dsp_get_vers(sb_devc * devc) in dsp_get_vers() argument
261 spin_lock_irqsave(&devc->lock, flags); in dsp_get_vers()
262 devc->major = devc->minor = 0; in dsp_get_vers()
263 sb_dsp_command(devc, 0xe1); /* Get version */ in dsp_get_vers()
269 if (devc->major == 0) in dsp_get_vers()
270 devc->major = inb(DSP_READ); in dsp_get_vers()
273 devc->minor = inb(DSP_READ); in dsp_get_vers()
278 spin_unlock_irqrestore(&devc->lock, flags); in dsp_get_vers()
279 DDB(printk("DSP version %d.%02d\n", devc->major, devc->minor)); in dsp_get_vers()
282 static int sb16_set_dma_hw(sb_devc * devc) in sb16_set_dma_hw() argument
286 if (devc->dma8 != 0 && devc->dma8 != 1 && devc->dma8 != 3) in sb16_set_dma_hw()
288 printk(KERN_ERR "SB16: Invalid 8 bit DMA (%d)\n", devc->dma8); in sb16_set_dma_hw()
291 bits = (1 << devc->dma8); in sb16_set_dma_hw()
293 if (devc->dma16 >= 5 && devc->dma16 <= 7) in sb16_set_dma_hw()
294 bits |= (1 << devc->dma16); in sb16_set_dma_hw()
296 sb_setmixer(devc, DMA_NR, bits); in sb16_set_dma_hw()
300 static void sb16_set_mpu_port(sb_devc * devc, struct address_info *hw_config) in sb16_set_mpu_port() argument
305 unsigned char bits = sb_getmixer(devc, 0x84) & ~0x06; in sb16_set_mpu_port()
310 sb_setmixer(devc, 0x84, bits | 0x04); in sb16_set_mpu_port()
314 sb_setmixer(devc, 0x84, bits | 0x00); in sb16_set_mpu_port()
318 sb_setmixer(devc, 0x84, bits | 0x02); /* Disable MPU */ in sb16_set_mpu_port()
323 static int sb16_set_irq_hw(sb_devc * devc, int level) in sb16_set_irq_hw() argument
345 sb_setmixer(devc, IRQ_NR, ival); in sb16_set_irq_hw()
349 static void relocate_Jazz16(sb_devc * devc, struct address_info *hw_config) in relocate_Jazz16() argument
384 static int init_Jazz16(sb_devc * devc, struct address_info *hw_config) in init_Jazz16() argument
392 if (!sb_dsp_command(devc, 0xfa)) in init_Jazz16()
395 if (sb_dsp_get_byte(devc) != 0x12) in init_Jazz16()
421 devc->dma16 = hw_config->dma2; in init_Jazz16()
423 if (!sb_dsp_command(devc, 0xfb)) in init_Jazz16()
426 if (!sb_dsp_command(devc, jazz_dma_bits[hw_config->dma] | in init_Jazz16()
430 if (!sb_dsp_command(devc, jazz_irq_bits[hw_config->irq])) in init_Jazz16()
436 devc->model = MDL_JAZZ; in init_Jazz16()
440 devc->caps |= SB_NO_MIDI; in init_Jazz16()
444 static void relocate_ess1688(sb_devc * devc) in relocate_ess1688() argument
448 switch (devc->base) in relocate_ess1688()
488 inb(devc->base); in relocate_ess1688()
489 if (sb_dsp_reset(devc)) /* Bingo */ in relocate_ess1688()
507 sb_devc *devc = &sb_info; in sb_dsp_detect() local
512 if(sbmo) memcpy(&devc->sbmo, sbmo, sizeof(struct sb_module_options)); in sb_dsp_detect()
524 spin_lock_init(&devc->lock); in sb_dsp_detect()
525 devc->type = hw_config->card_subtype; in sb_dsp_detect()
527 devc->base = hw_config->io_base; in sb_dsp_detect()
528 devc->irq = hw_config->irq; in sb_dsp_detect()
529 devc->dma8 = hw_config->dma; in sb_dsp_detect()
531 devc->dma16 = -1; in sb_dsp_detect()
532 devc->pcibase = pciio; in sb_dsp_detect()
536 devc->model = MDL_ESSPCI; in sb_dsp_detect()
537 devc->caps |= SB_PCI_IRQ; in sb_dsp_detect()
544 devc->model = MDL_YMPCI; in sb_dsp_detect()
545 devc->caps |= SB_PCI_IRQ; in sb_dsp_detect()
552 if (devc->sbmo.acer) in sb_dsp_detect()
556 spin_lock_irqsave(&devc->lock, flags); in sb_dsp_detect()
557 inb(devc->base + 0x09); in sb_dsp_detect()
558 inb(devc->base + 0x09); in sb_dsp_detect()
559 inb(devc->base + 0x09); in sb_dsp_detect()
560 inb(devc->base + 0x0b); in sb_dsp_detect()
561 inb(devc->base + 0x09); in sb_dsp_detect()
562 inb(devc->base + 0x0b); in sb_dsp_detect()
563 inb(devc->base + 0x09); in sb_dsp_detect()
564 inb(devc->base + 0x09); in sb_dsp_detect()
565 inb(devc->base + 0x0b); in sb_dsp_detect()
566 inb(devc->base + 0x09); in sb_dsp_detect()
567 inb(devc->base + 0x00); in sb_dsp_detect()
568 spin_unlock_irqrestore(&devc->lock, flags); in sb_dsp_detect()
574 if (sb_dsp_reset(devc)) in sb_dsp_detect()
575 dsp_get_vers(devc); in sb_dsp_detect()
577 devc->major = 0; in sb_dsp_detect()
579 if (devc->type == 0 || devc->type == MDL_JAZZ || devc->type == MDL_SMW) in sb_dsp_detect()
580 if (devc->major == 0 || (devc->major == 3 && devc->minor == 1)) in sb_dsp_detect()
581 relocate_Jazz16(devc, hw_config); in sb_dsp_detect()
583 if (devc->major == 0 && (devc->type == MDL_ESS || devc->type == 0)) in sb_dsp_detect()
584 relocate_ess1688(devc); in sb_dsp_detect()
586 if (!sb_dsp_reset(devc)) in sb_dsp_detect()
594 if (devc->major == 0) in sb_dsp_detect()
595 dsp_get_vers(devc); in sb_dsp_detect()
597 if (devc->major == 3 && devc->minor == 1) in sb_dsp_detect()
599 if (devc->type == MDL_AZTECH) /* SG Washington? */ in sb_dsp_detect()
601 if (sb_dsp_command(devc, 0x09)) in sb_dsp_detect()
602 if (sb_dsp_command(devc, 0x00)) /* Enter WSS mode */ in sb_dsp_detect()
609 devc->caps = SB_NO_AUDIO | SB_NO_MIDI; /* Mixer only */ in sb_dsp_detect()
610 devc->model = MDL_AZTECH; in sb_dsp_detect()
615 if(devc->type == MDL_ESSPCI) in sb_dsp_detect()
616 devc->model = MDL_ESSPCI; in sb_dsp_detect()
618 if(devc->type == MDL_YMPCI) in sb_dsp_detect()
621 devc->model = MDL_YMPCI; in sb_dsp_detect()
635 memcpy(detected_devc, devc, sizeof(sb_devc)); in sb_dsp_detect()
636 …MDB(printk(KERN_INFO "SB %d.%02d detected OK (%x)\n", devc->major, devc->minor, hw_config->io_base… in sb_dsp_detect()
642 sb_devc *devc; in sb_dsp_init() local
658 devc = detected_devc; in sb_dsp_init()
661 if (devc->base != hw_config->io_base) in sb_dsp_init()
664 release_region(devc->base, 16); in sb_dsp_init()
671 devc->caps = hw_config->driver_use_1; in sb_dsp_init()
673 if (!((devc->caps & SB_NO_AUDIO) && (devc->caps & SB_NO_MIDI)) && hw_config->irq > 0) in sb_dsp_init()
681 int i=(devc->caps&SB_PCI_IRQ)?IRQF_SHARED:0; in sb_dsp_init()
683 if (request_irq(hw_config->irq, sbintr, i, "soundblaster", devc) < 0) in sb_dsp_init()
686 release_region(devc->base, 16); in sb_dsp_init()
689 devc->irq_ok = 0; in sb_dsp_init()
691 if (devc->major == 4) in sb_dsp_init()
692 if (!sb16_set_irq_hw(devc, devc->irq)) /* Unsupported IRQ */ in sb_dsp_init()
694 free_irq(devc->irq, devc); in sb_dsp_init()
695 release_region(devc->base, 16); in sb_dsp_init()
698 if ((devc->type == 0 || devc->type == MDL_ESS) && in sb_dsp_init()
699 devc->major == 3 && devc->minor == 1) in sb_dsp_init()
701 if ((devc->type != 0 && devc->type != MDL_ESS) || in sb_dsp_init()
702 !ess_init(devc, hw_config)) in sb_dsp_init()
704 if ((devc->type != 0 && devc->type != MDL_JAZZ && in sb_dsp_init()
705 devc->type != MDL_SMW) || !init_Jazz16(devc, hw_config)) in sb_dsp_init()
711 if (devc->major == 4 && devc->minor <= 11 ) /* Won't work */ in sb_dsp_init()
712 devc->irq_ok = 1; in sb_dsp_init()
717 for (n = 0; n < 3 && devc->irq_ok == 0; n++) in sb_dsp_init()
719 if (sb_dsp_command(devc, 0xf2)) /* Cause interrupt immediately */ in sb_dsp_init()
723 for (i = 0; !devc->irq_ok && i < 10000; i++); in sb_dsp_init()
726 if (!devc->irq_ok) in sb_dsp_init()
727 printk(KERN_WARNING "sb: Interrupt test on IRQ%d failed - Probable IRQ conflict\n", devc->irq); in sb_dsp_init()
730 DDB(printk("IRQ test OK (IRQ%d)\n", devc->irq)); in sb_dsp_init()
735 last_sb = devc; in sb_dsp_init()
737 switch (devc->major) in sb_dsp_init()
740 devc->model = hw_config->card_subtype = MDL_SB1; in sb_dsp_init()
744 if (devc->minor == 0) in sb_dsp_init()
745 devc->model = hw_config->card_subtype = MDL_SB2; in sb_dsp_init()
747 devc->model = hw_config->card_subtype = MDL_SB201; in sb_dsp_init()
751 switch (devc->model) { in sb_dsp_init()
753 devc->model = hw_config->card_subtype = MDL_SBPRO; in sb_dsp_init()
758 ess_dsp_init(devc, hw_config); in sb_dsp_init()
764 devc->model = hw_config->card_subtype = MDL_SB16; in sb_dsp_init()
772 if ((devc->minor == 2) && sb_getmixer(devc,0x3c) && sb_getmixer(devc,0x4c)) in sb_dsp_init()
774 mixer30 = sb_getmixer(devc,0x30); in sb_dsp_init()
775 sb_setmixer(devc,0x22,(mixer22=sb_getmixer(devc,0x22)) & 0x0f); in sb_dsp_init()
776 sb_setmixer(devc,0x30,0xff); in sb_dsp_init()
779 if ((sb_getmixer(devc,0x30) != 0xff) || ((sb_getmixer(devc,0x22) & 0xf0) != 0x10)) in sb_dsp_init()
781 devc->submodel = SUBMDL_ALS100; in sb_dsp_init()
787 sb_setmixer(devc,0x3c,0x1f); /* Enable all inputs */ in sb_dsp_init()
788 sb_setmixer(devc,0x4c,0x1f); in sb_dsp_init()
789 sb_setmixer(devc,0x22,mixer22); /* Restore 0x22 to original value */ in sb_dsp_init()
790 devc->submodel = SUBMDL_ALS007; in sb_dsp_init()
794 sb_setmixer(devc,0x30,mixer30); in sb_dsp_init()
800 devc->dma16 = devc->dma8; in sb_dsp_init()
804 devc->dma16 = devc->dma8; in sb_dsp_init()
807 devc->dma16 = hw_config->dma2; in sb_dsp_init()
809 if(!sb16_set_dma_hw(devc)) { in sb_dsp_init()
810 free_irq(devc->irq, devc); in sb_dsp_init()
815 devc->caps |= SB_NO_MIDI; in sb_dsp_init()
818 if (!(devc->caps & SB_NO_MIXER)) in sb_dsp_init()
819 if (devc->major == 3 || devc->major == 4) in sb_dsp_init()
820 sb_mixer_init(devc, owner); in sb_dsp_init()
822 if (!(devc->caps & SB_NO_MIDI)) in sb_dsp_init()
823 sb_dsp_midi_init(devc, owner); in sb_dsp_init()
828 sprintf(name, "%s (%d.%02d)", hw_config->name, devc->major, devc->minor); in sb_dsp_init()
838 if (devc->model <= MDL_SBPRO) in sb_dsp_init()
840 …if (devc->major == 3 && devc->minor != 1) /* "True" SB Pro should have v3.1 (rare ones may have 3.… in sb_dsp_init()
847 else if (!sb_be_quiet && devc->model == MDL_SBPRO) in sb_dsp_init()
849 …N_INFO "SB DSP version is just %d.%02d which means that your card is\n", devc->major, devc->minor); in sb_dsp_init()
854 hw_config->card_subtype = devc->model; in sb_dsp_init()
855 hw_config->slots[0]=devc->dev; in sb_dsp_init()
856 last_devc = devc; /* For SB MPU detection */ in sb_dsp_init()
858 if (!(devc->caps & SB_NO_AUDIO) && devc->dma8 >= 0) in sb_dsp_init()
860 if (sound_alloc_dma(devc->dma8, "SoundBlaster8")) in sb_dsp_init()
862 printk(KERN_WARNING "Sound Blaster: Can't allocate 8 bit DMA channel %d\n", devc->dma8); in sb_dsp_init()
864 if (devc->dma16 >= 0 && devc->dma16 != devc->dma8) in sb_dsp_init()
866 if (sound_alloc_dma(devc->dma16, "SoundBlaster16")) in sb_dsp_init()
867 printk(KERN_WARNING "Sound Blaster: can't allocate 16 bit DMA channel %d.\n", devc->dma16); in sb_dsp_init()
869 sb_audio_init(devc, name, owner); in sb_dsp_init()
870 hw_config->slots[0]=devc->dev; in sb_dsp_init()
884 sb_devc *devc; in sb_dsp_unload() local
886 devc = audio_devs[hw_config->slots[0]]->devc; in sb_dsp_unload()
888 if (devc && devc->base == hw_config->io_base) in sb_dsp_unload()
890 if ((devc->model & MDL_ESS) && devc->pcibase) in sb_dsp_unload()
891 release_region(devc->pcibase, 8); in sb_dsp_unload()
893 release_region(devc->base, 16); in sb_dsp_unload()
895 if (!(devc->caps & SB_NO_AUDIO)) in sb_dsp_unload()
897 sound_free_dma(devc->dma8); in sb_dsp_unload()
898 if (devc->dma16 >= 0) in sb_dsp_unload()
899 sound_free_dma(devc->dma16); in sb_dsp_unload()
901 if (!(devc->caps & SB_NO_AUDIO && devc->caps & SB_NO_MIDI)) in sb_dsp_unload()
903 if (devc->irq > 0) in sb_dsp_unload()
904 free_irq(devc->irq, devc); in sb_dsp_unload()
906 sb_mixer_unload(devc); in sb_dsp_unload()
911 sound_unload_mididev(devc->my_mididev); in sb_dsp_unload()
912 sound_unload_audiodev(devc->dev); in sb_dsp_unload()
914 kfree(devc); in sb_dsp_unload()
929 void sb_setmixer(sb_devc * devc, unsigned int port, unsigned int value) in sb_setmixer() argument
933 if (devc->model == MDL_ESS) { in sb_setmixer()
934 ess_setmixer (devc, port, value); in sb_setmixer()
938 spin_lock_irqsave(&devc->lock, flags); in sb_setmixer()
945 spin_unlock_irqrestore(&devc->lock, flags); in sb_setmixer()
948 unsigned int sb_getmixer(sb_devc * devc, unsigned int port) in sb_getmixer() argument
953 if (devc->model == MDL_ESS) return ess_getmixer (devc, port); in sb_getmixer()
955 spin_lock_irqsave(&devc->lock, flags); in sb_getmixer()
962 spin_unlock_irqrestore(&devc->lock, flags); in sb_getmixer()
968 (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val) in sb_chgmixer() argument
972 value = sb_getmixer(devc, reg); in sb_chgmixer()
974 sb_setmixer(devc, reg, value); in sb_chgmixer()
981 static void smw_putmem(sb_devc * devc, int base, int addr, unsigned char val) in smw_putmem() argument
994 static unsigned char smw_getmem(sb_devc * devc, int base, int addr) in smw_getmem() argument
1009 static int smw_midi_init(sb_devc * devc, struct address_info *hw_config) in smw_midi_init() argument
1032 smw_putmem(devc, mp_base, 0, 0x00); in smw_midi_init()
1033 smw_putmem(devc, mp_base, 1, 0xff); in smw_midi_init()
1036 if (smw_getmem(devc, mp_base, 0) != 0x00 || smw_getmem(devc, mp_base, 1) != 0xff) in smw_midi_init()
1038 …o microcontroller RAM detected (%02x, %02x)\n", smw_getmem(devc, mp_base, 0), smw_getmem(devc, mp_… in smw_midi_init()
1045 devc->model = MDL_SMW; in smw_midi_init()
1046 smw_mixer_init(devc); in smw_midi_init()
1067 smw_putmem(devc, mp_base, i, smw_ucode[i]); in smw_midi_init()
1074 if (smw_getmem(devc, mp_base, i) != smw_ucode[i]) in smw_midi_init()
1114 static int init_Jazz16_midi(sb_devc * devc, struct address_info *hw_config) in init_Jazz16_midi() argument
1117 int sb_base = devc->base; in init_Jazz16_midi()
1172 smw_midi_init(devc, hw_config); in init_Jazz16_midi()
1174 if (!sb_dsp_command(devc, 0xfb)) in init_Jazz16_midi()
1177 if (!sb_dsp_command(devc, jazz_dma_bits[devc->dma8] | in init_Jazz16_midi()
1178 (jazz_dma_bits[devc->dma16] << 4))) in init_Jazz16_midi()
1181 if (!sb_dsp_command(devc, jazz_irq_bits[devc->irq] | in init_Jazz16_midi()
1190 sb_devc *devc = last_devc; in probe_sbmpu() local
1203 if(devc->model == MDL_SB16 && devc->minor >= 12) in probe_sbmpu()
1205 unsigned char bits = sb_getmixer(devc, 0x84) & ~0x06; in probe_sbmpu()
1206 sb_setmixer(devc, 0x84, bits | 0x02); /* Disable MPU */ in probe_sbmpu()
1212 if (devc->model == MDL_ESS) in probe_sbmpu()
1220 if (!ess_midi_init(devc, hw_config)) { in probe_sbmpu()
1225 devc->midi_irq_cookie = NULL; in probe_sbmpu()
1238 switch (devc->model) in probe_sbmpu()
1247 if (hw_config->irq < 3 || hw_config->irq == devc->irq) in probe_sbmpu()
1248 hw_config->irq = -devc->irq; in probe_sbmpu()
1249 if (devc->minor > 12) /* What is Vibra's version??? */ in probe_sbmpu()
1250 sb16_set_mpu_port(devc, hw_config); in probe_sbmpu()
1254 if (hw_config->irq < 3 || hw_config->irq == devc->irq) in probe_sbmpu()
1255 hw_config->irq = -devc->irq; in probe_sbmpu()
1256 if (!init_Jazz16_midi(devc, hw_config)) in probe_sbmpu()
1270 last_sb->midi_irq_cookie=midi_devs[hw_config->slots[4]]->devc; in probe_sbmpu()