Lines Matching refs:sonic

62 #define SV_REG(sonic, x) ((sonic)->enh_port + SV_REG_##x)  argument
252 static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic, in snd_sonicvibes_setdmaa() argument
257 outl(addr, sonic->dmaa_port + SV_DMA_ADDR0); in snd_sonicvibes_setdmaa()
258 outl(count, sonic->dmaa_port + SV_DMA_COUNT0); in snd_sonicvibes_setdmaa()
259 outb(0x18, sonic->dmaa_port + SV_DMA_MODE); in snd_sonicvibes_setdmaa()
261 dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n", in snd_sonicvibes_setdmaa()
262 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0)); in snd_sonicvibes_setdmaa()
266 static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic, in snd_sonicvibes_setdmac() argument
273 outl(addr, sonic->dmac_port + SV_DMA_ADDR0); in snd_sonicvibes_setdmac()
274 outl(count, sonic->dmac_port + SV_DMA_COUNT0); in snd_sonicvibes_setdmac()
275 outb(0x14, sonic->dmac_port + SV_DMA_MODE); in snd_sonicvibes_setdmac()
277 dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n", in snd_sonicvibes_setdmac()
278 addr, inl(sonic->dmac_port + SV_DMA_ADDR0)); in snd_sonicvibes_setdmac()
282 static inline unsigned int snd_sonicvibes_getdmaa(struct sonicvibes * sonic) in snd_sonicvibes_getdmaa() argument
284 return (inl(sonic->dmaa_port + SV_DMA_COUNT0) & 0xffffff) + 1; in snd_sonicvibes_getdmaa()
287 static inline unsigned int snd_sonicvibes_getdmac(struct sonicvibes * sonic) in snd_sonicvibes_getdmac() argument
290 return ((inl(sonic->dmac_port + SV_DMA_COUNT0) & 0xffffff) + 1) << 1; in snd_sonicvibes_getdmac()
293 static void snd_sonicvibes_out1(struct sonicvibes * sonic, in snd_sonicvibes_out1() argument
297 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_out1()
299 outb(value, SV_REG(sonic, DATA)); in snd_sonicvibes_out1()
303 static void snd_sonicvibes_out(struct sonicvibes * sonic, in snd_sonicvibes_out() argument
309 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_out()
310 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_out()
312 outb(value, SV_REG(sonic, DATA)); in snd_sonicvibes_out()
314 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_out()
317 static unsigned char snd_sonicvibes_in1(struct sonicvibes * sonic, unsigned char reg) in snd_sonicvibes_in1() argument
321 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_in1()
323 value = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_in1()
328 static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char reg) in snd_sonicvibes_in() argument
333 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_in()
334 outb(reg, SV_REG(sonic, INDEX)); in snd_sonicvibes_in()
336 value = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_in()
338 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_in()
343 static void snd_sonicvibes_debug(struct sonicvibes * sonic)
345 dev_dbg(sonic->card->dev,
347 inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS)));
348 dev_dbg(sonic->card->dev,
350 snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20));
351 dev_dbg(sonic->card->dev,
353 snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21));
354 dev_dbg(sonic->card->dev,
356 snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22));
357 dev_dbg(sonic->card->dev,
359 snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23));
360 dev_dbg(sonic->card->dev,
362 snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24));
363 dev_dbg(sonic->card->dev,
365 snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25));
366 dev_dbg(sonic->card->dev,
368 snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26));
369 dev_dbg(sonic->card->dev,
371 snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27));
372 dev_dbg(sonic->card->dev,
374 snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28));
375 dev_dbg(sonic->card->dev,
377 snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29));
378 dev_dbg(sonic->card->dev,
380 snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a));
381 dev_dbg(sonic->card->dev,
383 snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b));
384 dev_dbg(sonic->card->dev,
386 snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c));
387 dev_dbg(sonic->card->dev,
389 snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d));
390 dev_dbg(sonic->card->dev,
392 snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e));
393 dev_dbg(sonic->card->dev,
395 snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f));
396 dev_dbg(sonic->card->dev,
398 snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30));
399 dev_dbg(sonic->card->dev,
401 snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31));
402 dev_dbg(sonic->card->dev,
404 snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32));
405 dev_dbg(sonic->card->dev,
407 snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33));
408 dev_dbg(sonic->card->dev,
410 snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34));
411 dev_dbg(sonic->card->dev,
413 snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35));
414 dev_dbg(sonic->card->dev,
416 snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36));
417 dev_dbg(sonic->card->dev,
419 snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37));
420 dev_dbg(sonic->card->dev,
422 snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38));
423 dev_dbg(sonic->card->dev,
425 snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39));
426 dev_dbg(sonic->card->dev,
428 snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a));
429 dev_dbg(sonic->card->dev,
431 snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b));
432 dev_dbg(sonic->card->dev,
434 snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c));
435 dev_dbg(sonic->card->dev,
437 snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d));
438 dev_dbg(sonic->card->dev,
440 snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e));
441 dev_dbg(sonic->card->dev,
443 snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f));
448 static void snd_sonicvibes_setfmt(struct sonicvibes * sonic, in snd_sonicvibes_setfmt() argument
454 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_setfmt()
455 outb(SV_MCE | SV_IREG_DMA_DATA_FMT, SV_REG(sonic, INDEX)); in snd_sonicvibes_setfmt()
457 sonic->format = inb(SV_REG(sonic, DATA)); in snd_sonicvibes_setfmt()
460 sonic->format = (sonic->format & mask) | value; in snd_sonicvibes_setfmt()
461 outb(sonic->format, SV_REG(sonic, DATA)); in snd_sonicvibes_setfmt()
463 outb(0, SV_REG(sonic, INDEX)); in snd_sonicvibes_setfmt()
465 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_setfmt()
499 dev_dbg(sonic->card->dev, in snd_sonicvibes_pll()
501 dev_dbg(sonic->card->dev, in snd_sonicvibes_pll()
506 static void snd_sonicvibes_setpll(struct sonicvibes * sonic, in snd_sonicvibes_setpll() argument
514 if (sonic != NULL) { in snd_sonicvibes_setpll()
515 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_setpll()
516 snd_sonicvibes_out1(sonic, reg, m); in snd_sonicvibes_setpll()
517 snd_sonicvibes_out1(sonic, reg + 1, r | n); in snd_sonicvibes_setpll()
518 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_setpll()
522 static void snd_sonicvibes_set_adc_rate(struct sonicvibes * sonic, unsigned int rate) in snd_sonicvibes_set_adc_rate() argument
535 snd_sonicvibes_setpll(sonic, SV_IREG_ADC_PLL, rate); in snd_sonicvibes_set_adc_rate()
537 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_set_adc_rate()
538 snd_sonicvibes_out1(sonic, SV_IREG_ADC_ALT_RATE, (div - 1) << 4); in snd_sonicvibes_set_adc_rate()
539 snd_sonicvibes_out1(sonic, SV_IREG_ADC_CLOCK, clock); in snd_sonicvibes_set_adc_rate()
540 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_set_adc_rate()
568 static void snd_sonicvibes_set_dac_rate(struct sonicvibes * sonic, unsigned int rate) in snd_sonicvibes_set_dac_rate() argument
576 spin_lock_irqsave(&sonic->reg_lock, flags); in snd_sonicvibes_set_dac_rate()
577 snd_sonicvibes_out1(sonic, SV_IREG_PCM_RATE_HIGH, div >> 8); in snd_sonicvibes_set_dac_rate()
578 snd_sonicvibes_out1(sonic, SV_IREG_PCM_RATE_LOW, div); in snd_sonicvibes_set_dac_rate()
579 spin_unlock_irqrestore(&sonic->reg_lock, flags); in snd_sonicvibes_set_dac_rate()
582 static int snd_sonicvibes_trigger(struct sonicvibes * sonic, int what, int cmd) in snd_sonicvibes_trigger() argument
586 spin_lock(&sonic->reg_lock); in snd_sonicvibes_trigger()
588 if (!(sonic->enable & what)) { in snd_sonicvibes_trigger()
589 sonic->enable |= what; in snd_sonicvibes_trigger()
590 snd_sonicvibes_out1(sonic, SV_IREG_PC_ENABLE, sonic->enable); in snd_sonicvibes_trigger()
593 if (sonic->enable & what) { in snd_sonicvibes_trigger()
594 sonic->enable &= ~what; in snd_sonicvibes_trigger()
595 snd_sonicvibes_out1(sonic, SV_IREG_PC_ENABLE, sonic->enable); in snd_sonicvibes_trigger()
600 spin_unlock(&sonic->reg_lock); in snd_sonicvibes_trigger()
606 struct sonicvibes *sonic = dev_id; in snd_sonicvibes_interrupt() local
609 status = inb(SV_REG(sonic, STATUS)); in snd_sonicvibes_interrupt()
613 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_interrupt()
614 dev_err(sonic->card->dev, in snd_sonicvibes_interrupt()
618 if (sonic->pcm) { in snd_sonicvibes_interrupt()
620 snd_pcm_period_elapsed(sonic->playback_substream); in snd_sonicvibes_interrupt()
622 snd_pcm_period_elapsed(sonic->capture_substream); in snd_sonicvibes_interrupt()
624 if (sonic->rmidi) { in snd_sonicvibes_interrupt()
626 snd_mpu401_uart_interrupt(irq, sonic->rmidi->private_data); in snd_sonicvibes_interrupt()
632 spin_lock(&sonic->reg_lock); in snd_sonicvibes_interrupt()
633 udreg = snd_sonicvibes_in1(sonic, SV_IREG_UD_BUTTON); in snd_sonicvibes_interrupt()
637 oleft = mleft = snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ANALOG); in snd_sonicvibes_interrupt()
638 oright = mright = snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ANALOG); in snd_sonicvibes_interrupt()
657 snd_sonicvibes_out1(sonic, SV_IREG_LEFT_ANALOG, oleft); in snd_sonicvibes_interrupt()
658 snd_sonicvibes_out1(sonic, SV_IREG_RIGHT_ANALOG, oright); in snd_sonicvibes_interrupt()
659 spin_unlock(&sonic->reg_lock); in snd_sonicvibes_interrupt()
660 snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_mute->id); in snd_sonicvibes_interrupt()
661 snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_volume->id); in snd_sonicvibes_interrupt()
673 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_trigger() local
674 return snd_sonicvibes_trigger(sonic, 1, cmd); in snd_sonicvibes_playback_trigger()
680 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_trigger() local
681 return snd_sonicvibes_trigger(sonic, 2, cmd); in snd_sonicvibes_capture_trigger()
686 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_prepare() local
692 sonic->p_dma_size = size; in snd_sonicvibes_playback_prepare()
698 snd_sonicvibes_setfmt(sonic, ~3, fmt); in snd_sonicvibes_playback_prepare()
699 snd_sonicvibes_set_dac_rate(sonic, runtime->rate); in snd_sonicvibes_playback_prepare()
700 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_playback_prepare()
701 snd_sonicvibes_setdmaa(sonic, runtime->dma_addr, size); in snd_sonicvibes_playback_prepare()
702 snd_sonicvibes_out1(sonic, SV_IREG_DMA_A_UPPER, count >> 8); in snd_sonicvibes_playback_prepare()
703 snd_sonicvibes_out1(sonic, SV_IREG_DMA_A_LOWER, count); in snd_sonicvibes_playback_prepare()
704 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_playback_prepare()
710 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_prepare() local
716 sonic->c_dma_size = size; in snd_sonicvibes_capture_prepare()
723 snd_sonicvibes_setfmt(sonic, ~0x30, fmt); in snd_sonicvibes_capture_prepare()
724 snd_sonicvibes_set_adc_rate(sonic, runtime->rate); in snd_sonicvibes_capture_prepare()
725 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_capture_prepare()
726 snd_sonicvibes_setdmac(sonic, runtime->dma_addr, size); in snd_sonicvibes_capture_prepare()
727 snd_sonicvibes_out1(sonic, SV_IREG_DMA_C_UPPER, count >> 8); in snd_sonicvibes_capture_prepare()
728 snd_sonicvibes_out1(sonic, SV_IREG_DMA_C_LOWER, count); in snd_sonicvibes_capture_prepare()
729 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_capture_prepare()
735 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_pointer() local
738 if (!(sonic->enable & 1)) in snd_sonicvibes_playback_pointer()
740 ptr = sonic->p_dma_size - snd_sonicvibes_getdmaa(sonic); in snd_sonicvibes_playback_pointer()
746 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_pointer() local
748 if (!(sonic->enable & 2)) in snd_sonicvibes_capture_pointer()
750 ptr = sonic->c_dma_size - snd_sonicvibes_getdmac(sonic); in snd_sonicvibes_capture_pointer()
794 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_open() local
797 sonic->mode |= SV_MODE_PLAY; in snd_sonicvibes_playback_open()
798 sonic->playback_substream = substream; in snd_sonicvibes_playback_open()
806 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_open() local
809 sonic->mode |= SV_MODE_CAPTURE; in snd_sonicvibes_capture_open()
810 sonic->capture_substream = substream; in snd_sonicvibes_capture_open()
819 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_playback_close() local
821 sonic->playback_substream = NULL; in snd_sonicvibes_playback_close()
822 sonic->mode &= ~SV_MODE_PLAY; in snd_sonicvibes_playback_close()
828 struct sonicvibes *sonic = snd_pcm_substream_chip(substream); in snd_sonicvibes_capture_close() local
830 sonic->capture_substream = NULL; in snd_sonicvibes_capture_close()
831 sonic->mode &= ~SV_MODE_CAPTURE; in snd_sonicvibes_capture_close()
851 static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) in snd_sonicvibes_pcm() argument
856 if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0) in snd_sonicvibes_pcm()
864 pcm->private_data = sonic; in snd_sonicvibes_pcm()
867 sonic->pcm = pcm; in snd_sonicvibes_pcm()
870 &sonic->pci->dev, 64*1024, 128*1024); in snd_sonicvibes_pcm()
895 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_mux() local
897 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_mux()
898 …ucontrol->value.enumerated.item[0] = ((snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ADC) & SV_RECSRC_OUT… in snd_sonicvibes_get_mux()
899 …ucontrol->value.enumerated.item[1] = ((snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ADC) & SV_RECSRC_OU… in snd_sonicvibes_get_mux()
900 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_mux()
906 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_mux() local
915 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_mux()
916 oval1 = snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ADC); in snd_sonicvibes_put_mux()
917 oval2 = snd_sonicvibes_in1(sonic, SV_IREG_RIGHT_ADC); in snd_sonicvibes_put_mux()
921 snd_sonicvibes_out1(sonic, SV_IREG_LEFT_ADC, left); in snd_sonicvibes_put_mux()
922 snd_sonicvibes_out1(sonic, SV_IREG_RIGHT_ADC, right); in snd_sonicvibes_put_mux()
923 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_mux()
946 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_single() local
952 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_single()
953 ucontrol->value.integer.value[0] = (snd_sonicvibes_in1(sonic, reg)>> shift) & mask; in snd_sonicvibes_get_single()
954 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_single()
962 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_single() local
974 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_single()
975 oval = snd_sonicvibes_in1(sonic, reg); in snd_sonicvibes_put_single()
978 snd_sonicvibes_out1(sonic, reg, val); in snd_sonicvibes_put_single()
979 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_single()
1002 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_get_double() local
1010 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_get_double()
1011 ucontrol->value.integer.value[0] = (snd_sonicvibes_in1(sonic, left_reg) >> shift_left) & mask; in snd_sonicvibes_get_double()
1012 ucontrol->value.integer.value[1] = (snd_sonicvibes_in1(sonic, right_reg) >> shift_right) & mask; in snd_sonicvibes_get_double()
1013 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_get_double()
1023 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_put_double() local
1041 spin_lock_irq(&sonic->reg_lock); in snd_sonicvibes_put_double()
1042 oval1 = snd_sonicvibes_in1(sonic, left_reg); in snd_sonicvibes_put_double()
1043 oval2 = snd_sonicvibes_in1(sonic, right_reg); in snd_sonicvibes_put_double()
1047 snd_sonicvibes_out1(sonic, left_reg, val1); in snd_sonicvibes_put_double()
1048 snd_sonicvibes_out1(sonic, right_reg, val2); in snd_sonicvibes_put_double()
1049 spin_unlock_irq(&sonic->reg_lock); in snd_sonicvibes_put_double()
1079 struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); in snd_sonicvibes_master_free() local
1080 sonic->master_mute = NULL; in snd_sonicvibes_master_free()
1081 sonic->master_volume = NULL; in snd_sonicvibes_master_free()
1084 static int snd_sonicvibes_mixer(struct sonicvibes *sonic) in snd_sonicvibes_mixer() argument
1091 if (snd_BUG_ON(!sonic || !sonic->card)) in snd_sonicvibes_mixer()
1093 card = sonic->card; in snd_sonicvibes_mixer()
1097 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_sonicvibes_controls[idx], sonic))) < 0) in snd_sonicvibes_mixer()
1114 struct sonicvibes *sonic = entry->private_data; in snd_sonicvibes_proc_read() local
1117 tmp = sonic->srs_space & 0x0f; in snd_sonicvibes_proc_read()
1119 sonic->srs_space & 0x80 ? "off" : "on"); in snd_sonicvibes_proc_read()
1125 tmp = sonic->srs_center & 0x0f; in snd_sonicvibes_proc_read()
1131 tmp = sonic->wave_source & 0x03; in snd_sonicvibes_proc_read()
1135 tmp = sonic->mpu_switch; in snd_sonicvibes_proc_read()
1141 static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) in snd_sonicvibes_proc_init() argument
1143 snd_card_ro_proc_new(sonic->card, "sonicvibes", sonic, in snd_sonicvibes_proc_init()
1155 static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) in snd_sonicvibes_create_gameport() argument
1160 sonic->gameport = gp = gameport_allocate_port(); in snd_sonicvibes_create_gameport()
1162 dev_err(sonic->card->dev, in snd_sonicvibes_create_gameport()
1168 gameport_set_phys(gp, "pci%s/gameport0", pci_name(sonic->pci)); in snd_sonicvibes_create_gameport()
1169 gameport_set_dev_parent(gp, &sonic->pci->dev); in snd_sonicvibes_create_gameport()
1170 gp->io = sonic->game_port; in snd_sonicvibes_create_gameport()
1174 err = snd_ctl_add(sonic->card, in snd_sonicvibes_create_gameport()
1175 snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); in snd_sonicvibes_create_gameport()
1182 static void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) in snd_sonicvibes_free_gameport() argument
1184 if (sonic->gameport) { in snd_sonicvibes_free_gameport()
1185 gameport_unregister_port(sonic->gameport); in snd_sonicvibes_free_gameport()
1186 sonic->gameport = NULL; in snd_sonicvibes_free_gameport()
1190 static inline int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { return -ENOSYS; } in snd_sonicvibes_create_gameport() argument
1191 static inline void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) { } in snd_sonicvibes_free_gameport() argument
1194 static int snd_sonicvibes_free(struct sonicvibes *sonic) in snd_sonicvibes_free() argument
1196 snd_sonicvibes_free_gameport(sonic); in snd_sonicvibes_free()
1197 pci_write_config_dword(sonic->pci, 0x40, sonic->dmaa_port); in snd_sonicvibes_free()
1198 pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port); in snd_sonicvibes_free()
1199 if (sonic->irq >= 0) in snd_sonicvibes_free()
1200 free_irq(sonic->irq, sonic); in snd_sonicvibes_free()
1201 release_and_free_resource(sonic->res_dmaa); in snd_sonicvibes_free()
1202 release_and_free_resource(sonic->res_dmac); in snd_sonicvibes_free()
1203 pci_release_regions(sonic->pci); in snd_sonicvibes_free()
1204 pci_disable_device(sonic->pci); in snd_sonicvibes_free()
1205 kfree(sonic); in snd_sonicvibes_free()
1211 struct sonicvibes *sonic = device->device_data; in snd_sonicvibes_dev_free() local
1212 return snd_sonicvibes_free(sonic); in snd_sonicvibes_dev_free()
1221 struct sonicvibes *sonic; in snd_sonicvibes_create() local
1241 sonic = kzalloc(sizeof(*sonic), GFP_KERNEL); in snd_sonicvibes_create()
1242 if (sonic == NULL) { in snd_sonicvibes_create()
1246 spin_lock_init(&sonic->reg_lock); in snd_sonicvibes_create()
1247 sonic->card = card; in snd_sonicvibes_create()
1248 sonic->pci = pci; in snd_sonicvibes_create()
1249 sonic->irq = -1; in snd_sonicvibes_create()
1252 kfree(sonic); in snd_sonicvibes_create()
1257 sonic->sb_port = pci_resource_start(pci, 0); in snd_sonicvibes_create()
1258 sonic->enh_port = pci_resource_start(pci, 1); in snd_sonicvibes_create()
1259 sonic->synth_port = pci_resource_start(pci, 2); in snd_sonicvibes_create()
1260 sonic->midi_port = pci_resource_start(pci, 3); in snd_sonicvibes_create()
1261 sonic->game_port = pci_resource_start(pci, 4); in snd_sonicvibes_create()
1264 KBUILD_MODNAME, sonic)) { in snd_sonicvibes_create()
1266 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1269 sonic->irq = pci->irq; in snd_sonicvibes_create()
1270 card->sync_irq = sonic->irq; in snd_sonicvibes_create()
1294 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) { in snd_sonicvibes_create()
1295 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1301 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) { in snd_sonicvibes_create()
1302 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1309 pci_read_config_dword(pci, 0x40, &sonic->dmaa_port); in snd_sonicvibes_create()
1310 pci_read_config_dword(pci, 0x48, &sonic->dmac_port); in snd_sonicvibes_create()
1311 sonic->dmaa_port &= ~0x0f; in snd_sonicvibes_create()
1312 sonic->dmac_port &= ~0x0f; in snd_sonicvibes_create()
1313 pci_write_config_dword(pci, 0x40, sonic->dmaa_port | 9); /* enable + enhanced */ in snd_sonicvibes_create()
1314 pci_write_config_dword(pci, 0x48, sonic->dmac_port | 9); /* enable */ in snd_sonicvibes_create()
1316 outb(SV_RESET, SV_REG(sonic, CONTROL)); /* reset chip */ in snd_sonicvibes_create()
1318 outb(0, SV_REG(sonic, CONTROL)); /* release reset */ in snd_sonicvibes_create()
1320 outb(SV_ENHANCED | SV_INTA | (reverb ? SV_REVERB : 0), SV_REG(sonic, CONTROL)); in snd_sonicvibes_create()
1321 inb(SV_REG(sonic, STATUS)); /* clear IRQs */ in snd_sonicvibes_create()
1323 snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0); /* drive current 16mA */ in snd_sonicvibes_create()
1325 snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0x40); /* drive current 8mA */ in snd_sonicvibes_create()
1327 snd_sonicvibes_out(sonic, SV_IREG_PC_ENABLE, sonic->enable = 0); /* disable playback & capture */ in snd_sonicvibes_create()
1328 outb(sonic->irqmask = ~(SV_DMAA_MASK | SV_DMAC_MASK | SV_UD_MASK), SV_REG(sonic, IRQMASK)); in snd_sonicvibes_create()
1329 inb(SV_REG(sonic, STATUS)); /* clear IRQs */ in snd_sonicvibes_create()
1330 snd_sonicvibes_out(sonic, SV_IREG_ADC_CLOCK, 0); /* use PLL as clock source */ in snd_sonicvibes_create()
1331 snd_sonicvibes_out(sonic, SV_IREG_ANALOG_POWER, 0); /* power up analog parts */ in snd_sonicvibes_create()
1332 snd_sonicvibes_out(sonic, SV_IREG_DIGITAL_POWER, 0); /* power up digital parts */ in snd_sonicvibes_create()
1333 snd_sonicvibes_setpll(sonic, SV_IREG_ADC_PLL, 8000); in snd_sonicvibes_create()
1334 snd_sonicvibes_out(sonic, SV_IREG_SRS_SPACE, sonic->srs_space = 0x80); /* SRS space off */ in snd_sonicvibes_create()
1335 snd_sonicvibes_out(sonic, SV_IREG_SRS_CENTER, sonic->srs_center = 0x00);/* SRS center off */ in snd_sonicvibes_create()
1336 snd_sonicvibes_out(sonic, SV_IREG_MPU401, sonic->mpu_switch = 0x05); /* MPU-401 switch */ in snd_sonicvibes_create()
1337 snd_sonicvibes_out(sonic, SV_IREG_WAVE_SOURCE, sonic->wave_source = 0x00); /* onboard ROM */ in snd_sonicvibes_create()
1338 snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_LOW, (8000 * 65536 / SV_FULLRATE) & 0xff); in snd_sonicvibes_create()
1339 snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_HIGH, ((8000 * 65536 / SV_FULLRATE) >> 8) & 0xff); in snd_sonicvibes_create()
1340 snd_sonicvibes_out(sonic, SV_IREG_LEFT_ADC, mge ? 0xd0 : 0xc0); in snd_sonicvibes_create()
1341 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ADC, 0xc0); in snd_sonicvibes_create()
1342 snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX1, 0x9f); in snd_sonicvibes_create()
1343 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX1, 0x9f); in snd_sonicvibes_create()
1344 snd_sonicvibes_out(sonic, SV_IREG_LEFT_CD, 0x9f); in snd_sonicvibes_create()
1345 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_CD, 0x9f); in snd_sonicvibes_create()
1346 snd_sonicvibes_out(sonic, SV_IREG_LEFT_LINE, 0x9f); in snd_sonicvibes_create()
1347 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_LINE, 0x9f); in snd_sonicvibes_create()
1348 snd_sonicvibes_out(sonic, SV_IREG_MIC, 0x8f); in snd_sonicvibes_create()
1349 snd_sonicvibes_out(sonic, SV_IREG_LEFT_SYNTH, 0x9f); in snd_sonicvibes_create()
1350 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_SYNTH, 0x9f); in snd_sonicvibes_create()
1351 snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX2, 0x9f); in snd_sonicvibes_create()
1352 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX2, 0x9f); in snd_sonicvibes_create()
1353 snd_sonicvibes_out(sonic, SV_IREG_LEFT_ANALOG, 0x9f); in snd_sonicvibes_create()
1354 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ANALOG, 0x9f); in snd_sonicvibes_create()
1355 snd_sonicvibes_out(sonic, SV_IREG_LEFT_PCM, 0xbf); in snd_sonicvibes_create()
1356 snd_sonicvibes_out(sonic, SV_IREG_RIGHT_PCM, 0xbf); in snd_sonicvibes_create()
1357 snd_sonicvibes_out(sonic, SV_IREG_ADC_OUTPUT_CTRL, 0xfc); in snd_sonicvibes_create()
1359 snd_sonicvibes_debug(sonic); in snd_sonicvibes_create()
1361 sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION); in snd_sonicvibes_create()
1363 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) { in snd_sonicvibes_create()
1364 snd_sonicvibes_free(sonic); in snd_sonicvibes_create()
1368 snd_sonicvibes_proc_init(sonic); in snd_sonicvibes_create()
1370 *rsonic = sonic; in snd_sonicvibes_create()
1388 struct sonicvibes *sonic = mpu->private_data; in snd_sonicvibes_midi_input_open() local
1389 outb(sonic->irqmask &= ~SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_midi_input_open()
1395 struct sonicvibes *sonic = mpu->private_data; in snd_sonicvibes_midi_input_close() local
1396 outb(sonic->irqmask |= SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); in snd_sonicvibes_midi_input_close()
1399 static int snd_sonicvibes_midi(struct sonicvibes *sonic, in snd_sonicvibes_midi() argument
1403 struct snd_card *card = sonic->card; in snd_sonicvibes_midi()
1407 mpu->private_data = sonic; in snd_sonicvibes_midi()
1411 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_midi_controls[idx], sonic))) < 0) in snd_sonicvibes_midi()
1421 struct sonicvibes *sonic; in snd_sonic_probe() local
1447 &sonic)) < 0) { in snd_sonic_probe()
1456 sonic->revision, in snd_sonic_probe()
1458 sonic->irq); in snd_sonic_probe()
1460 if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) { in snd_sonic_probe()
1464 if ((err = snd_sonicvibes_mixer(sonic)) < 0) { in snd_sonic_probe()
1469 sonic->midi_port, in snd_sonic_probe()
1476 snd_sonicvibes_midi(sonic, midi_uart); in snd_sonic_probe()
1477 if ((err = snd_opl3_create(card, sonic->synth_port, in snd_sonic_probe()
1478 sonic->synth_port + 2, in snd_sonic_probe()
1488 err = snd_sonicvibes_create_gameport(sonic); in snd_sonic_probe()