Lines Matching refs:sonic
76 #define SV_REG(sonic, x) ((sonic)->enh_port + SV_REG_##x) argument
266 static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic, in snd_sonicvibes_setdmaa() argument
271 outl(addr, sonic->dmaa_port + SV_DMA_ADDR0); in snd_sonicvibes_setdmaa()
272 outl(count, sonic->dmaa_port + SV_DMA_COUNT0); in snd_sonicvibes_setdmaa()
273 outb(0x18, sonic->dmaa_port + SV_DMA_MODE); in snd_sonicvibes_setdmaa()
275 dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n", in snd_sonicvibes_setdmaa()
276 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0)); in snd_sonicvibes_setdmaa()
280 static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic, in snd_sonicvibes_setdmac() argument
287 outl(addr, sonic->dmac_port + SV_DMA_ADDR0); in snd_sonicvibes_setdmac()
288 outl(count, sonic->dmac_port + SV_DMA_COUNT0); in snd_sonicvibes_setdmac()
289 outb(0x14, sonic->dmac_port + SV_DMA_MODE); in snd_sonicvibes_setdmac()
291 dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n", in snd_sonicvibes_setdmac()
292 addr, inl(sonic->dmac_port + SV_DMA_ADDR0)); in snd_sonicvibes_setdmac()
296 static inline unsigned int snd_sonicvibes_getdmaa(struct sonicvibes * sonic) in snd_sonicvibes_getdmaa() argument
298 return (inl(sonic->dmaa_port + SV_DMA_COUNT0) & 0xffffff) + 1; in snd_sonicvibes_getdmaa()
301 static inline unsigned int snd_sonicvibes_getdmac(struct sonicvibes * sonic) in snd_sonicvibes_getdmac() argument
304 return ((inl(sonic->dmac_port + SV_DMA_COUNT0) & 0xffffff) + 1) << 1; in snd_sonicvibes_getdmac()
307 static void snd_sonicvibes_out1(struct sonicvibes * sonic, in snd_sonicvibes_out1() argument
311 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_out1()
313 outb(value, SV_REG(sonic, DATA)); in snd_sonicvibes_out1()
317 static void snd_sonicvibes_out(struct sonicvibes * sonic, in snd_sonicvibes_out() argument
323 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_out()
324 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_out()
326 outb(value, SV_REG(sonic, DATA)); in snd_sonicvibes_out()
328 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_out()
331 static unsigned char snd_sonicvibes_in1(struct sonicvibes * sonic, unsigned char reg) in snd_sonicvibes_in1() argument
335 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_in1()
337 value = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_in1()
342 static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char reg) in snd_sonicvibes_in() argument
347 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_in()
348 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_in()
350 value = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_in()
352 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_in()
357 static void snd_sonicvibes_debug(struct sonicvibes * sonic)
359 dev_dbg(sonic->card->dev,
361 inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS)));
362 dev_dbg(sonic->card->dev,
364 snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20));
365 dev_dbg(sonic->card->dev,
367 snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21));
368 dev_dbg(sonic->card->dev,
370 snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22));
371 dev_dbg(sonic->card->dev,
373 snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23));
374 dev_dbg(sonic->card->dev,
376 snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24));
377 dev_dbg(sonic->card->dev,
379 snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25));
380 dev_dbg(sonic->card->dev,
382 snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26));
383 dev_dbg(sonic->card->dev,
385 snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27));
386 dev_dbg(sonic->card->dev,
388 snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28));
389 dev_dbg(sonic->card->dev,
391 snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29));
392 dev_dbg(sonic->card->dev,
394 snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a));
395 dev_dbg(sonic->card->dev,
397 snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b));
398 dev_dbg(sonic->card->dev,
400 snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c));
401 dev_dbg(sonic->card->dev,
403 snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d));
404 dev_dbg(sonic->card->dev,
406 snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e));
407 dev_dbg(sonic->card->dev,
409 snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f));
410 dev_dbg(sonic->card->dev,
412 snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30));
413 dev_dbg(sonic->card->dev,
415 snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31));
416 dev_dbg(sonic->card->dev,
418 snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32));
419 dev_dbg(sonic->card->dev,
421 snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33));
422 dev_dbg(sonic->card->dev,
424 snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34));
425 dev_dbg(sonic->card->dev,
427 snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35));
428 dev_dbg(sonic->card->dev,
430 snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36));
431 dev_dbg(sonic->card->dev,
433 snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37));
434 dev_dbg(sonic->card->dev,
436 snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38));
437 dev_dbg(sonic->card->dev,
439 snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39));
440 dev_dbg(sonic->card->dev,
442 snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a));
443 dev_dbg(sonic->card->dev,
445 snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b));
446 dev_dbg(sonic->card->dev,
448 snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c));
449 dev_dbg(sonic->card->dev,
451 snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d));
452 dev_dbg(sonic->card->dev,
454 snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e));
455 dev_dbg(sonic->card->dev,
457 snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f));
462 static void snd_sonicvibes_setfmt(struct sonicvibes * sonic, in snd_sonicvibes_setfmt() argument
468 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_setfmt()
469 outb(SV_MCE | SV_IREG_DMA_DATA_FMT, SV_REG(sonic, INDEX)); in snd_sonicvibes_setfmt()
471 sonic->format = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_setfmt()
474 sonic->format = (sonic->format & mask) | value; in snd_sonicvibes_setfmt()
475 outb(sonic->format, SV_REG(sonic, DATA)); in snd_sonicvibes_setfmt()
477 outb(0, SV_REG(sonic, INDEX)); in snd_sonicvibes_setfmt()
479 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_setfmt()
513 dev_dbg(sonic->card->dev, in snd_sonicvibes_pll()
515 dev_dbg(sonic->card->dev, in snd_sonicvibes_pll()
520 static void snd_sonicvibes_setpll(struct sonicvibes * sonic, in snd_sonicvibes_setpll() argument
528 if (sonic != NULL) { in snd_sonicvibes_setpll()
529 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_setpll()
530 snd_sonicvibes_out1(sonic, reg, m); in snd_sonicvibes_setpll()
531 snd_sonicvibes_out1(sonic, reg + 1, r | n); in snd_sonicvibes_setpll()
532 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_setpll()
536 static void snd_sonicvibes_set_adc_rate(struct sonicvibes * sonic, unsigned int rate) in snd_sonicvibes_set_adc_rate() argument
549 snd_sonicvibes_setpll(sonic, SV_IREG_ADC_PLL, rate); in snd_sonicvibes_set_adc_rate()
551 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_set_adc_rate()
552 snd_sonicvibes_out1(sonic, SV_IREG_ADC_ALT_RATE, (div - 1) << 4); in snd_sonicvibes_set_adc_rate()
553 snd_sonicvibes_out1(sonic, SV_IREG_ADC_CLOCK, clock); in snd_sonicvibes_set_adc_rate()
554 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_set_adc_rate()
582 static void snd_sonicvibes_set_dac_rate(struct sonicvibes * sonic, unsigned int rate) in snd_sonicvibes_set_dac_rate() argument
590 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_set_dac_rate()
591 snd_sonicvibes_out1(sonic, SV_IREG_PCM_RATE_HIGH, div >> 8); in snd_sonicvibes_set_dac_rate()
592 snd_sonicvibes_out1(sonic, SV_IREG_PCM_RATE_LOW, div); in snd_sonicvibes_set_dac_rate()
593 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_set_dac_rate()
596 static int snd_sonicvibes_trigger(struct sonicvibes * sonic, int what, int cmd) in snd_sonicvibes_trigger() argument
600 spin_lock(&sonic->reg_lock); in snd_sonicvibes_trigger()
602 if (!(sonic->enable & what)) { in snd_sonicvibes_trigger()
603 sonic->enable |= what; in snd_sonicvibes_trigger()
604 snd_sonicvibes_out1(sonic, SV_IREG_PC_ENABLE, sonic->enable); in snd_sonicvibes_trigger()
607 if (sonic->enable & what) { in snd_sonicvibes_trigger()
608 sonic->enable &= ~what; in snd_sonicvibes_trigger()
609 snd_sonicvibes_out1(sonic, SV_IREG_PC_ENABLE, sonic->enable); in snd_sonicvibes_trigger()
614 spin_unlock(&sonic->reg_lock); in snd_sonicvibes_trigger()
620 struct sonicvibes *sonic = dev_id; in snd_sonicvibes_interrupt() local
623 status = inb(SV_REG(sonic, STATUS)); in snd_sonicvibes_interrupt()
627 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_interrupt()
628 dev_err(sonic->card->dev, in snd_sonicvibes_interrupt()
632 if (sonic->pcm) { in snd_sonicvibes_interrupt()
634 snd_pcm_period_elapsed(sonic->playback_substream); in snd_sonicvibes_interrupt()
636 snd_pcm_period_elapsed(sonic->capture_substream); in snd_sonicvibes_interrupt()
638 if (sonic->rmidi) { in snd_sonicvibes_interrupt()
640 snd_mpu401_uart_interrupt(irq, sonic->rmidi->private_data); in snd_sonicvibes_interrupt()
646 spin_lock(&sonic->reg_lock); in snd_sonicvibes_interrupt()
647 udreg = snd_sonicvibes_in1(sonic, SV_IREG_UD_BUTTON); in snd_sonicvibes_interrupt()
651 oleft = mleft = snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ANALOG); in snd_sonicvibes_interrupt()
652 oright = mright = snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ANALOG); in snd_sonicvibes_interrupt()
671 snd_sonicvibes_out1(sonic, SV_IREG_LEFT_ANALOG, oleft); in snd_sonicvibes_interrupt()
672 snd_sonicvibes_out1(sonic, SV_IREG_RIGHT_ANALOG, oright); in snd_sonicvibes_interrupt()
673 spin_unlock(&sonic->reg_lock); in snd_sonicvibes_interrupt()
674 snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_mute->id); in snd_sonicvibes_interrupt()
675 snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_volume->id); in snd_sonicvibes_interrupt()
687 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_trigger() local
688 return snd_sonicvibes_trigger(sonic, 1, cmd); in snd_sonicvibes_playback_trigger()
694 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_trigger() local
695 return snd_sonicvibes_trigger(sonic, 2, cmd); in snd_sonicvibes_capture_trigger()
711 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_prepare() local
717 sonic->p_dma_size = size; in snd_sonicvibes_playback_prepare()
723 snd_sonicvibes_setfmt(sonic, ~3, fmt); in snd_sonicvibes_playback_prepare()
724 snd_sonicvibes_set_dac_rate(sonic, runtime->rate); in snd_sonicvibes_playback_prepare()
725 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_playback_prepare()
726 snd_sonicvibes_setdmaa(sonic, runtime->dma_addr, size); in snd_sonicvibes_playback_prepare()
727 snd_sonicvibes_out1(sonic, SV_IREG_DMA_A_UPPER, count >> 8); in snd_sonicvibes_playback_prepare()
728 snd_sonicvibes_out1(sonic, SV_IREG_DMA_A_LOWER, count); in snd_sonicvibes_playback_prepare()
729 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_playback_prepare()
735 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_prepare() local
741 sonic->c_dma_size = size; in snd_sonicvibes_capture_prepare()
748 snd_sonicvibes_setfmt(sonic, ~0x30, fmt); in snd_sonicvibes_capture_prepare()
749 snd_sonicvibes_set_adc_rate(sonic, runtime->rate); in snd_sonicvibes_capture_prepare()
750 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_capture_prepare()
751 snd_sonicvibes_setdmac(sonic, runtime->dma_addr, size); in snd_sonicvibes_capture_prepare()
752 snd_sonicvibes_out1(sonic, SV_IREG_DMA_C_UPPER, count >> 8); in snd_sonicvibes_capture_prepare()
753 snd_sonicvibes_out1(sonic, SV_IREG_DMA_C_LOWER, count); in snd_sonicvibes_capture_prepare()
754 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_capture_prepare()
760 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_pointer() local
763 if (!(sonic->enable & 1)) in snd_sonicvibes_playback_pointer()
765 ptr = sonic->p_dma_size - snd_sonicvibes_getdmaa(sonic); in snd_sonicvibes_playback_pointer()
771 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_pointer() local
773 if (!(sonic->enable & 2)) in snd_sonicvibes_capture_pointer()
775 ptr = sonic->c_dma_size - snd_sonicvibes_getdmac(sonic); in snd_sonicvibes_capture_pointer()
819 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_open() local
822 sonic->mode |= SV_MODE_PLAY; in snd_sonicvibes_playback_open()
823 sonic->playback_substream = substream; in snd_sonicvibes_playback_open()
831 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_open() local
834 sonic->mode |= SV_MODE_CAPTURE; in snd_sonicvibes_capture_open()
835 sonic->capture_substream = substream; in snd_sonicvibes_capture_open()
844 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_close() local
846 sonic->playback_substream = NULL; in snd_sonicvibes_playback_close()
847 sonic->mode &= ~SV_MODE_PLAY; in snd_sonicvibes_playback_close()
853 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_close() local
855 sonic->capture_substream = NULL; in snd_sonicvibes_capture_close()
856 sonic->mode &= ~SV_MODE_CAPTURE; in snd_sonicvibes_capture_close()
882 static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) in snd_sonicvibes_pcm() argument
887 if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0) in snd_sonicvibes_pcm()
895 pcm->private_data = sonic; in snd_sonicvibes_pcm()
898 sonic->pcm = pcm; in snd_sonicvibes_pcm()
901 snd_dma_pci_data(sonic->pci), 64*1024, 128*1024); in snd_sonicvibes_pcm()
926 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_mux() local
928 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_mux()
929 …ucontrol->value.enumerated.item[0] = ((snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ADC) & SV_RECSRC_OUT… in snd_sonicvibes_get_mux()
930 …ucontrol->value.enumerated.item[1] = ((snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ADC) & SV_RECSRC_OU… in snd_sonicvibes_get_mux()
931 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_mux()
937 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_mux() local
946 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_mux()
947 oval1 = snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ADC); in snd_sonicvibes_put_mux()
948 oval2 = snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ADC); in snd_sonicvibes_put_mux()
952 snd_sonicvibes_out1(sonic, SV_IREG_LEFT_ADC, left); in snd_sonicvibes_put_mux()
953 snd_sonicvibes_out1(sonic, SV_IREG_RIGHT_ADC, right); in snd_sonicvibes_put_mux()
954 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_mux()
977 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_single() local
983 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_single()
984 ucontrol->value.integer.value[0] = (snd_sonicvibes_in1(sonic, reg)>> shift) & mask; in snd_sonicvibes_get_single()
985 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_single()
993 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_single() local
1005 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_single()
1006 oval = snd_sonicvibes_in1(sonic, reg); in snd_sonicvibes_put_single()
1009 snd_sonicvibes_out1(sonic, reg, val); in snd_sonicvibes_put_single()
1010 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_single()
1033 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_double() local
1041 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_double()
1042 ucontrol->value.integer.value[0] = (snd_sonicvibes_in1(sonic, left_reg) >> shift_left) & mask; in snd_sonicvibes_get_double()
1043 ucontrol->value.integer.value[1] = (snd_sonicvibes_in1(sonic, right_reg) >> shift_right) & mask; in snd_sonicvibes_get_double()
1044 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_double()
1054 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_double() local
1072 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_double()
1073 oval1 = snd_sonicvibes_in1(sonic, left_reg); in snd_sonicvibes_put_double()
1074 oval2 = snd_sonicvibes_in1(sonic, right_reg); in snd_sonicvibes_put_double()
1078 snd_sonicvibes_out1(sonic, left_reg, val1); in snd_sonicvibes_put_double()
1079 snd_sonicvibes_out1(sonic, right_reg, val2); in snd_sonicvibes_put_double()
1080 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_double()
1110 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_master_free() local
1111 sonic->master_mute = NULL; in snd_sonicvibes_master_free()
1112 sonic->master_volume = NULL; in snd_sonicvibes_master_free()
1115 static int snd_sonicvibes_mixer(struct sonicvibes *sonic) in snd_sonicvibes_mixer() argument
1122 if (snd_BUG_ON(!sonic || !sonic->card)) in snd_sonicvibes_mixer()
1124 card = sonic->card; in snd_sonicvibes_mixer()
1128 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_sonicvibes_controls[idx], sonic))) < 0) in snd_sonicvibes_mixer()
1145 struct sonicvibes *sonic = entry->private_data; in snd_sonicvibes_proc_read() local
1148 tmp = sonic->srs_space & 0x0f; in snd_sonicvibes_proc_read()
1150 sonic->srs_space & 0x80 ? "off" : "on"); in snd_sonicvibes_proc_read()
1156 tmp = sonic->srs_center & 0x0f; in snd_sonicvibes_proc_read()
1162 tmp = sonic->wave_source & 0x03; in snd_sonicvibes_proc_read()
1166 tmp = sonic->mpu_switch; in snd_sonicvibes_proc_read()
1172 static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) in snd_sonicvibes_proc_init() argument
1176 if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry)) in snd_sonicvibes_proc_init()
1177 snd_info_set_text_ops(entry, sonic, snd_sonicvibes_proc_read); in snd_sonicvibes_proc_init()
1188 static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) in snd_sonicvibes_create_gameport() argument
1192 sonic->gameport = gp = gameport_allocate_port(); in snd_sonicvibes_create_gameport()
1194 dev_err(sonic->card->dev, in snd_sonicvibes_create_gameport()
1200 gameport_set_phys(gp, "pci%s/gameport0", pci_name(sonic->pci)); in snd_sonicvibes_create_gameport()
1201 gameport_set_dev_parent(gp, &sonic->pci->dev); in snd_sonicvibes_create_gameport()
1202 gp->io = sonic->game_port; in snd_sonicvibes_create_gameport()
1206 snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); in snd_sonicvibes_create_gameport()
1211 static void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) in snd_sonicvibes_free_gameport() argument
1213 if (sonic->gameport) { in snd_sonicvibes_free_gameport()
1214 gameport_unregister_port(sonic->gameport); in snd_sonicvibes_free_gameport()
1215 sonic->gameport = NULL; in snd_sonicvibes_free_gameport()
1219 static inline int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { return -ENOSYS; } in snd_sonicvibes_create_gameport() argument
1220 static inline void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) { } in snd_sonicvibes_free_gameport() argument
1223 static int snd_sonicvibes_free(struct sonicvibes *sonic) in snd_sonicvibes_free() argument
1225 snd_sonicvibes_free_gameport(sonic); in snd_sonicvibes_free()
1226 pci_write_config_dword(sonic->pci, 0x40, sonic->dmaa_port); in snd_sonicvibes_free()
1227 pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port); in snd_sonicvibes_free()
1228 if (sonic->irq >= 0) in snd_sonicvibes_free()
1229 free_irq(sonic->irq, sonic); in snd_sonicvibes_free()
1230 release_and_free_resource(sonic->res_dmaa); in snd_sonicvibes_free()
1231 release_and_free_resource(sonic->res_dmac); in snd_sonicvibes_free()
1232 pci_release_regions(sonic->pci); in snd_sonicvibes_free()
1233 pci_disable_device(sonic->pci); in snd_sonicvibes_free()
1234 kfree(sonic); in snd_sonicvibes_free()
1240 struct sonicvibes *sonic = device->device_data; in snd_sonicvibes_dev_free() local
1241 return snd_sonicvibes_free(sonic); in snd_sonicvibes_dev_free()
1250 struct sonicvibes *sonic; in snd_sonicvibes_create() local
1270 sonic = kzalloc(sizeof(*sonic), GFP_KERNEL); in snd_sonicvibes_create()
1271 if (sonic == NULL) { in snd_sonicvibes_create()
1275 spin_lock_init(&sonic->reg_lock); in snd_sonicvibes_create()
1276 sonic->card = card; in snd_sonicvibes_create()
1277 sonic->pci = pci; in snd_sonicvibes_create()
1278 sonic->irq = -1; in snd_sonicvibes_create()
1281 kfree(sonic); in snd_sonicvibes_create()
1286 sonic->sb_port = pci_resource_start(pci, 0); in snd_sonicvibes_create()
1287 sonic->enh_port = pci_resource_start(pci, 1); in snd_sonicvibes_create()
1288 sonic->synth_port = pci_resource_start(pci, 2); in snd_sonicvibes_create()
1289 sonic->midi_port = pci_resource_start(pci, 3); in snd_sonicvibes_create()
1290 sonic->game_port = pci_resource_start(pci, 4); in snd_sonicvibes_create()
1293 KBUILD_MODNAME, sonic)) { in snd_sonicvibes_create()
1295 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1298 sonic->irq = pci->irq; in snd_sonicvibes_create()
1322 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) { in snd_sonicvibes_create()
1323 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1329 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) { in snd_sonicvibes_create()
1330 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1337 pci_read_config_dword(pci, 0x40, &sonic->dmaa_port); in snd_sonicvibes_create()
1338 pci_read_config_dword(pci, 0x48, &sonic->dmac_port); in snd_sonicvibes_create()
1339 sonic->dmaa_port &= ~0x0f; in snd_sonicvibes_create()
1340 sonic->dmac_port &= ~0x0f; in snd_sonicvibes_create()
1341 pci_write_config_dword(pci, 0x40, sonic->dmaa_port | 9); /* enable + enhanced */ in snd_sonicvibes_create()
1342 pci_write_config_dword(pci, 0x48, sonic->dmac_port | 9); /* enable */ in snd_sonicvibes_create()
1344 outb(SV_RESET, SV_REG(sonic, CONTROL)); /* reset chip */ in snd_sonicvibes_create()
1346 outb(0, SV_REG(sonic, CONTROL)); /* release reset */ in snd_sonicvibes_create()
1348 outb(SV_ENHANCED | SV_INTA | (reverb ? SV_REVERB : 0), SV_REG(sonic, CONTROL)); in snd_sonicvibes_create()
1349 inb(SV_REG(sonic, STATUS)); /* clear IRQs */ in snd_sonicvibes_create()
1351 snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0); /* drive current 16mA */ in snd_sonicvibes_create()
1353 snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0x40); /* drive current 8mA */ in snd_sonicvibes_create()
1355 snd_sonicvibes_out(sonic, SV_IREG_PC_ENABLE, sonic->enable = 0); /* disable playback & capture */ in snd_sonicvibes_create()
1356 outb(sonic->irqmask = ~(SV_DMAA_MASK | SV_DMAC_MASK | SV_UD_MASK), SV_REG(sonic, IRQMASK)); in snd_sonicvibes_create()
1357 inb(SV_REG(sonic, STATUS)); /* clear IRQs */ in snd_sonicvibes_create()
1358 snd_sonicvibes_out(sonic, SV_IREG_ADC_CLOCK, 0); /* use PLL as clock source */ in snd_sonicvibes_create()
1359 snd_sonicvibes_out(sonic, SV_IREG_ANALOG_POWER, 0); /* power up analog parts */ in snd_sonicvibes_create()
1360 snd_sonicvibes_out(sonic, SV_IREG_DIGITAL_POWER, 0); /* power up digital parts */ in snd_sonicvibes_create()
1361 snd_sonicvibes_setpll(sonic, SV_IREG_ADC_PLL, 8000); in snd_sonicvibes_create()
1362 snd_sonicvibes_out(sonic, SV_IREG_SRS_SPACE, sonic->srs_space = 0x80); /* SRS space off */ in snd_sonicvibes_create()
1363 snd_sonicvibes_out(sonic, SV_IREG_SRS_CENTER, sonic->srs_center = 0x00);/* SRS center off */ in snd_sonicvibes_create()
1364 snd_sonicvibes_out(sonic, SV_IREG_MPU401, sonic->mpu_switch = 0x05); /* MPU-401 switch */ in snd_sonicvibes_create()
1365 snd_sonicvibes_out(sonic, SV_IREG_WAVE_SOURCE, sonic->wave_source = 0x00); /* onboard ROM */ in snd_sonicvibes_create()
1366 snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_LOW, (8000 * 65536 / SV_FULLRATE) & 0xff); in snd_sonicvibes_create()
1367 snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_HIGH, ((8000 * 65536 / SV_FULLRATE) >> 8) & 0xff); in snd_sonicvibes_create()
1368 snd_sonicvibes_out(sonic, SV_IREG_LEFT_ADC, mge ? 0xd0 : 0xc0); in snd_sonicvibes_create()
1369 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ADC, 0xc0); in snd_sonicvibes_create()
1370 snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX1, 0x9f); in snd_sonicvibes_create()
1371 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX1, 0x9f); in snd_sonicvibes_create()
1372 snd_sonicvibes_out(sonic, SV_IREG_LEFT_CD, 0x9f); in snd_sonicvibes_create()
1373 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_CD, 0x9f); in snd_sonicvibes_create()
1374 snd_sonicvibes_out(sonic, SV_IREG_LEFT_LINE, 0x9f); in snd_sonicvibes_create()
1375 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_LINE, 0x9f); in snd_sonicvibes_create()
1376 snd_sonicvibes_out(sonic, SV_IREG_MIC, 0x8f); in snd_sonicvibes_create()
1377 snd_sonicvibes_out(sonic, SV_IREG_LEFT_SYNTH, 0x9f); in snd_sonicvibes_create()
1378 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_SYNTH, 0x9f); in snd_sonicvibes_create()
1379 snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX2, 0x9f); in snd_sonicvibes_create()
1380 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX2, 0x9f); in snd_sonicvibes_create()
1381 snd_sonicvibes_out(sonic, SV_IREG_LEFT_ANALOG, 0x9f); in snd_sonicvibes_create()
1382 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ANALOG, 0x9f); in snd_sonicvibes_create()
1383 snd_sonicvibes_out(sonic, SV_IREG_LEFT_PCM, 0xbf); in snd_sonicvibes_create()
1384 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_PCM, 0xbf); in snd_sonicvibes_create()
1385 snd_sonicvibes_out(sonic, SV_IREG_ADC_OUTPUT_CTRL, 0xfc); in snd_sonicvibes_create()
1387 snd_sonicvibes_debug(sonic); in snd_sonicvibes_create()
1389 sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION); in snd_sonicvibes_create()
1391 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) { in snd_sonicvibes_create()
1392 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1396 snd_sonicvibes_proc_init(sonic); in snd_sonicvibes_create()
1398 *rsonic = sonic; in snd_sonicvibes_create()
1416 struct sonicvibes *sonic = mpu->private_data; in snd_sonicvibes_midi_input_open() local
1417 outb(sonic->irqmask &= ~SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_midi_input_open()
1423 struct sonicvibes *sonic = mpu->private_data; in snd_sonicvibes_midi_input_close() local
1424 outb(sonic->irqmask |= SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_midi_input_close()
1427 static int snd_sonicvibes_midi(struct sonicvibes *sonic, in snd_sonicvibes_midi() argument
1431 struct snd_card *card = sonic->card; in snd_sonicvibes_midi()
1436 mpu->private_data = sonic; in snd_sonicvibes_midi()
1441 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_midi_controls[idx], sonic))) < 0) in snd_sonicvibes_midi()
1451 struct sonicvibes *sonic; in snd_sonic_probe() local
1477 &sonic)) < 0) { in snd_sonic_probe()
1486 sonic->revision, in snd_sonic_probe()
1488 sonic->irq); in snd_sonic_probe()
1490 if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) { in snd_sonic_probe()
1494 if ((err = snd_sonicvibes_mixer(sonic)) < 0) { in snd_sonic_probe()
1499 sonic->midi_port, in snd_sonic_probe()
1506 snd_sonicvibes_midi(sonic, midi_uart); in snd_sonic_probe()
1507 if ((err = snd_opl3_create(card, sonic->synth_port, in snd_sonic_probe()
1508 sonic->synth_port + 2, in snd_sonic_probe()
1518 snd_sonicvibes_create_gameport(sonic); in snd_sonic_probe()