Lines Matching +full:serial +full:- +full:midi

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
12 * (One can use a standard mono mini-jack to one RCA plugs cable.
13 * or one can use a standard stereo mini-jack to two RCA plugs cable.
23 * The only playback controls that currently do anything are: -
82 * Implement support for Line-in capture on SB Live 24bit.
89 * Some stability problems when unloading the snd-ca0106 kernel module.
90 * --
95 * MIDI
96 * --
99 * P17 Chip: CA0106-DAT
102 * DAC: WM8746EDS (6-channel, 24bit, 192Khz)
106 * P17 Chip: CA0106-DAT
109 * DAC: CS4382 (114 dB, 24-Bit, 192 kHz, 8-Channel D/A Converter with DSD Support)
115 * P17 Chip: CA0106-DAT
130 #include <linux/dma-mapping.h>
137 MODULE_AUTHOR("James Courtier-Dutton <James@superbug.demon.co.uk>");
159 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
164 { .serial = 0x10131102,
165 .name = "X-Fi Extreme Audio [SBxxxx]",
168 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
171 * CTRL:CA0111-WTLF
173 * DAC: CS4382-KQZ
178 * Not-Tested:
182 { .serial = 0x10121102,
183 .name = "X-Fi Extreme Audio [SB0790]",
188 { .serial = 0x10021102,
192 { .serial = 0x10051102,
196 { .serial = 0x10061102,
201 { .serial = 0x10071102,
207 * CTRL:CA0106-DAT
211 { .serial = 0x100a1102,
218 * CTRL:CA0106-DAT
222 { .serial = 0x10111102,
229 * Not-Tested: Capture
231 { .serial = 0x10041102,
239 * CTRL:CA0106-DAT
241 * DAC: CS4382-KQZ
243 { .serial = 0x10091462,
248 { .serial = 0x10091102,
253 /* Giga-byte GA-G1975X mobo
257 { .serial = 0x1458a006,
258 .name = "Giga-byte GA-G1975X",
262 * Sound Blaster Live! 24-bit EAX
263 * high-definition 7.1 audio processor".
266 { .serial = 0x30381297,
271 * Sound Blaster Live! 24-bit EAX
272 * high-definition 7.1 audio processor".
275 { .serial = 0x30411297,
279 { .serial = 0,
297 .buffer_bytes_max = ((65536 - 64) * 8),
299 .period_bytes_max = (65536 - 64),
323 .buffer_bytes_max = 65536 - 128,
325 .period_bytes_max = 32768 - 64,
340 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ptr_read()
341 outl(regptr, emu->port + CA0106_PTR); in snd_ca0106_ptr_read()
342 val = inl(emu->port + CA0106_DATA); in snd_ca0106_ptr_read()
343 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ptr_read()
357 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ptr_write()
358 outl(regptr, emu->port + CA0106_PTR); in snd_ca0106_ptr_write()
359 outl(data, emu->port + CA0106_DATA); in snd_ca0106_ptr_write()
360 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ptr_write()
405 dev_err(emu->card->dev, "i2c_write: invalid values.\n"); in snd_ca0106_i2c_write()
406 return -EINVAL; in snd_ca0106_i2c_write()
411 dev_dbg(emu->card->dev, "I2C-write:reg=0x%x, value=0x%x\n", reg, value); in snd_ca0106_i2c_write()
430 /*dev_dbg(emu->card->dev, "I2C:status=0x%x\n", status);*/ in snd_ca0106_i2c_write()
444 dev_err(emu->card->dev, "Writing to ADC failed!\n"); in snd_ca0106_i2c_write()
445 return -EINVAL; in snd_ca0106_i2c_write()
457 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_intr_enable()
458 intr_enable = inl(emu->port + CA0106_INTE) | intrenb; in snd_ca0106_intr_enable()
459 outl(intr_enable, emu->port + CA0106_INTE); in snd_ca0106_intr_enable()
460 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_intr_enable()
468 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_intr_disable()
469 intr_enable = inl(emu->port + CA0106_INTE) & ~intrenb; in snd_ca0106_intr_disable()
470 outl(intr_enable, emu->port + CA0106_INTE); in snd_ca0106_intr_disable()
471 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_intr_disable()
477 kfree(runtime->private_data); in snd_ca0106_pcm_free_substream()
497 if (chip->spdif_str_bits[idx] != chip->spdif_bits[idx]) { in restore_spdif_bits()
498 chip->spdif_str_bits[idx] = chip->spdif_bits[idx]; in restore_spdif_bits()
500 chip->spdif_str_bits[idx]); in restore_spdif_bits()
510 return (details->spi_dac & 0xf000) >> (4 * 3); in snd_ca0106_channel_dac()
512 return (details->spi_dac & 0x0f00) >> (4 * 2); in snd_ca0106_channel_dac()
514 return (details->spi_dac & 0x00f0) >> (4 * 1); in snd_ca0106_channel_dac()
516 return (details->spi_dac & 0x000f) >> (4 * 0); in snd_ca0106_channel_dac()
518 dev_dbg(chip->card->dev, "ca0106: unknown channel_id %d\n", in snd_ca0106_channel_dac()
527 if (chip->details->spi_dac) { in snd_ca0106_pcm_power_dac()
528 const int dac = snd_ca0106_channel_dac(chip, chip->details, in snd_ca0106_pcm_power_dac()
535 chip->spi_dac_reg[reg] &= ~bit; in snd_ca0106_pcm_power_dac()
538 chip->spi_dac_reg[reg] |= bit; in snd_ca0106_pcm_power_dac()
539 if (snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]) != 0) in snd_ca0106_pcm_power_dac()
540 return -ENXIO; in snd_ca0106_pcm_power_dac()
550 struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); in snd_ca0106_pcm_open_playback_channel()
552 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_open_playback_channel()
558 return -ENOMEM; in snd_ca0106_pcm_open_playback_channel()
559 epcm->emu = chip; in snd_ca0106_pcm_open_playback_channel()
560 epcm->substream = substream; in snd_ca0106_pcm_open_playback_channel()
561 epcm->channel_id=channel_id; in snd_ca0106_pcm_open_playback_channel()
563 runtime->private_data = epcm; in snd_ca0106_pcm_open_playback_channel()
564 runtime->private_free = snd_ca0106_pcm_free_substream; in snd_ca0106_pcm_open_playback_channel()
566 runtime->hw = snd_ca0106_playback_hw; in snd_ca0106_pcm_open_playback_channel()
568 channel->emu = chip; in snd_ca0106_pcm_open_playback_channel()
569 channel->number = channel_id; in snd_ca0106_pcm_open_playback_channel()
571 channel->use = 1; in snd_ca0106_pcm_open_playback_channel()
573 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", in snd_ca0106_pcm_open_playback_channel()
576 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; in snd_ca0106_pcm_open_playback_channel()
577 channel->epcm = epcm; in snd_ca0106_pcm_open_playback_channel()
602 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_close_playback()
603 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_close_playback()
604 chip->playback_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_playback()
606 restore_spdif_bits(chip, epcm->channel_id); in snd_ca0106_pcm_close_playback()
609 if (epcm->channel_id != PCM_FRONT_CHANNEL) { in snd_ca0106_pcm_close_playback()
611 err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0); in snd_ca0106_pcm_close_playback()
645 struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); in snd_ca0106_pcm_open_capture_channel()
647 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_open_capture_channel()
652 return -ENOMEM; in snd_ca0106_pcm_open_capture_channel()
654 epcm->emu = chip; in snd_ca0106_pcm_open_capture_channel()
655 epcm->substream = substream; in snd_ca0106_pcm_open_capture_channel()
656 epcm->channel_id=channel_id; in snd_ca0106_pcm_open_capture_channel()
658 runtime->private_data = epcm; in snd_ca0106_pcm_open_capture_channel()
659 runtime->private_free = snd_ca0106_pcm_free_substream; in snd_ca0106_pcm_open_capture_channel()
661 runtime->hw = snd_ca0106_capture_hw; in snd_ca0106_pcm_open_capture_channel()
663 channel->emu = chip; in snd_ca0106_pcm_open_capture_channel()
664 channel->number = channel_id; in snd_ca0106_pcm_open_capture_channel()
666 channel->use = 1; in snd_ca0106_pcm_open_capture_channel()
668 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", in snd_ca0106_pcm_open_capture_channel()
671 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; in snd_ca0106_pcm_open_capture_channel()
672 channel->epcm = epcm; in snd_ca0106_pcm_open_capture_channel()
687 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_close_capture()
688 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_close_capture()
689 chip->capture_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_capture()
718 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_prepare_playback()
719 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_prepare_playback()
720 int channel = epcm->channel_id; in snd_ca0106_pcm_prepare_playback()
721 u32 *table_base = (u32 *)(emu->buffer->area+(8*16*channel)); in snd_ca0106_pcm_prepare_playback()
722 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); in snd_ca0106_pcm_prepare_playback()
736 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
740 channel, runtime->rate, runtime->format, in snd_ca0106_pcm_prepare_playback()
741 runtime->channels, runtime->buffer_size, in snd_ca0106_pcm_prepare_playback()
742 runtime->period_size, runtime->periods, in snd_ca0106_pcm_prepare_playback()
744 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
746 runtime->dma_addr, runtime->dma_area, table_base); in snd_ca0106_pcm_prepare_playback()
747 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
749 emu->buffer->addr, emu->buffer->area, emu->buffer->bytes); in snd_ca0106_pcm_prepare_playback()
754 switch (runtime->rate) { in snd_ca0106_pcm_prepare_playback()
778 switch (runtime->format) { in snd_ca0106_pcm_prepare_playback()
789 hcfg = inl(emu->port + CA0106_HCFG) ; in snd_ca0106_pcm_prepare_playback()
791 outl(hcfg, emu->port + CA0106_HCFG); in snd_ca0106_pcm_prepare_playback()
799 /* FIXME: Check emu->buffer->size before actually writing to it. */ in snd_ca0106_pcm_prepare_playback()
800 for(i=0; i < runtime->periods; i++) { in snd_ca0106_pcm_prepare_playback()
801 table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); in snd_ca0106_pcm_prepare_playback()
805 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer->addr+(8*16*channel)); in snd_ca0106_pcm_prepare_playback()
806 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); in snd_ca0106_pcm_prepare_playback()
808 snd_ca0106_ptr_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); in snd_ca0106_pcm_prepare_playback()
809 …snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_… in snd_ca0106_pcm_prepare_playback()
831 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_prepare_capture()
832 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_prepare_capture()
833 int channel = epcm->channel_id; in snd_ca0106_pcm_prepare_capture()
843 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
847 channel, runtime->rate, runtime->format, in snd_ca0106_pcm_prepare_capture()
848 runtime->channels, runtime->buffer_size, in snd_ca0106_pcm_prepare_capture()
849 runtime->period_size, runtime->periods, in snd_ca0106_pcm_prepare_capture()
851 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
853 runtime->dma_addr, runtime->dma_area, table_base); in snd_ca0106_pcm_prepare_capture()
854 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
856 emu->buffer->addr, emu->buffer->area, emu->buffer->bytes); in snd_ca0106_pcm_prepare_capture()
859 switch (runtime->rate) { in snd_ca0106_pcm_prepare_capture()
880 switch (runtime->format) { in snd_ca0106_pcm_prepare_capture()
891 hcfg = inl(emu->port + CA0106_HCFG) ; in snd_ca0106_pcm_prepare_capture()
893 outl(hcfg, emu->port + CA0106_HCFG); in snd_ca0106_pcm_prepare_capture()
897 if (emu->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ in snd_ca0106_pcm_prepare_capture()
903 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
906 channel, runtime->rate, runtime->format, runtime->channels, in snd_ca0106_pcm_prepare_capture()
907 runtime->buffer_size, runtime->period_size, in snd_ca0106_pcm_prepare_capture()
911 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); in snd_ca0106_pcm_prepare_capture()
912 …snd_ca0106_ptr_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_s… in snd_ca0106_pcm_prepare_capture()
946 s->stream != SNDRV_PCM_STREAM_PLAYBACK) in snd_ca0106_pcm_trigger_playback()
948 runtime = s->runtime; in snd_ca0106_pcm_trigger_playback()
949 epcm = runtime->private_data; in snd_ca0106_pcm_trigger_playback()
950 channel = epcm->channel_id; in snd_ca0106_pcm_trigger_playback()
951 /* dev_dbg(emu->card->dev, "channel=%d\n", channel); */ in snd_ca0106_pcm_trigger_playback()
952 epcm->running = running; in snd_ca0106_pcm_trigger_playback()
957 /* dev_dbg(emu->card->dev, "basic=0x%x, extended=0x%x\n",basic, extended); */ in snd_ca0106_pcm_trigger_playback()
979 result = -EINVAL; in snd_ca0106_pcm_trigger_playback()
990 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_trigger_capture()
991 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_trigger_capture()
992 int channel = epcm->channel_id; in snd_ca0106_pcm_trigger_capture()
999 epcm->running = 1; in snd_ca0106_pcm_trigger_capture()
1004 epcm->running = 0; in snd_ca0106_pcm_trigger_capture()
1007 result = -EINVAL; in snd_ca0106_pcm_trigger_capture()
1018 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_pointer_playback()
1019 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_pointer_playback()
1021 int channel = epcm->channel_id; in snd_ca0106_pcm_pointer_playback()
1024 if (!epcm->running) in snd_ca0106_pcm_pointer_playback()
1027 prev_ptr = -1; in snd_ca0106_pcm_pointer_playback()
1030 ptr = (ptr >> 3) * runtime->period_size; in snd_ca0106_pcm_pointer_playback()
1033 if (ptr >= runtime->buffer_size) in snd_ca0106_pcm_pointer_playback()
1034 ptr -= runtime->buffer_size; in snd_ca0106_pcm_pointer_playback()
1038 } while (--timeout); in snd_ca0106_pcm_pointer_playback()
1039 dev_warn(emu->card->dev, "ca0106: unstable DMA pointer!\n"); in snd_ca0106_pcm_pointer_playback()
1048 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_pointer_capture()
1049 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_pointer_capture()
1051 int channel = epcm->channel_id; in snd_ca0106_pcm_pointer_capture()
1053 if (!epcm->running) in snd_ca0106_pcm_pointer_capture()
1059 if (ptr >= runtime->buffer_size) in snd_ca0106_pcm_pointer_capture()
1060 ptr -= runtime->buffer_size; in snd_ca0106_pcm_pointer_capture()
1062 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " in snd_ca0106_pcm_pointer_capture()
1064 ptr1, ptr2, ptr, (int)runtime->buffer_size, in snd_ca0106_pcm_pointer_capture()
1065 (int)runtime->period_size, (int)runtime->frame_bits, in snd_ca0106_pcm_pointer_capture()
1066 (int)runtime->rate); in snd_ca0106_pcm_pointer_capture()
1140 struct snd_ca0106 *emu = ac97->private_data; in snd_ca0106_ac97_read()
1144 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ac97_read()
1145 outb(reg, emu->port + CA0106_AC97ADDRESS); in snd_ca0106_ac97_read()
1146 val = inw(emu->port + CA0106_AC97DATA); in snd_ca0106_ac97_read()
1147 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ac97_read()
1154 struct snd_ca0106 *emu = ac97->private_data; in snd_ca0106_ac97_write()
1157 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ac97_write()
1158 outb(reg, emu->port + CA0106_AC97ADDRESS); in snd_ca0106_ac97_write()
1159 outw(val, emu->port + CA0106_AC97DATA); in snd_ca0106_ac97_write()
1160 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ac97_write()
1173 err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus); in snd_ca0106_ac97()
1176 pbus->no_vra = 1; /* we don't need VRA */ in snd_ca0106_ac97()
1181 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_ca0106_ac97()
1188 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_free()
1203 status = inl(chip->port + CA0106_IPR); in snd_ca0106_interrupt()
1209 dev_dbg(emu->card->dev, "interrupt status = 0x%08x, stat76=0x%08x\n", in snd_ca0106_interrupt()
1211 dev_dbg(emu->card->dev, "ptr=0x%08x\n", in snd_ca0106_interrupt()
1216 pchannel = &(chip->playback_channels[i]); in snd_ca0106_interrupt()
1219 if(pchannel->use) { in snd_ca0106_interrupt()
1220 snd_pcm_period_elapsed(pchannel->epcm->substream); in snd_ca0106_interrupt()
1221 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */ in snd_ca0106_interrupt()
1225 dev_dbg(emu->card->dev, "channel=%p\n", pchannel); in snd_ca0106_interrupt()
1226 …dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->… in snd_ca0106_interrupt()
1232 pchannel = &(chip->capture_channels[i]); in snd_ca0106_interrupt()
1235 if(pchannel->use) { in snd_ca0106_interrupt()
1236 snd_pcm_period_elapsed(pchannel->epcm->substream); in snd_ca0106_interrupt()
1237 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */ in snd_ca0106_interrupt()
1241 dev_dbg(emu->card->dev, "channel=%p\n", pchannel); in snd_ca0106_interrupt()
1242 …dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->… in snd_ca0106_interrupt()
1249 if (chip->midi.dev_id && in snd_ca0106_interrupt()
1250 (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { in snd_ca0106_interrupt()
1251 if (chip->midi.interrupt) in snd_ca0106_interrupt()
1252 chip->midi.interrupt(&chip->midi, status); in snd_ca0106_interrupt()
1254 chip->midi.interrupt_disable(&chip->midi, chip->midi.tx_enable | chip->midi.rx_enable); in snd_ca0106_interrupt()
1258 outl(status, chip->port + CA0106_IPR); in snd_ca0106_interrupt()
1288 err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm); in snd_ca0106_pcm()
1292 pcm->private_data = emu; in snd_ca0106_pcm()
1317 pcm->info_flags = 0; in snd_ca0106_pcm()
1318 strcpy(pcm->name, "CA0106"); in snd_ca0106_pcm()
1320 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in snd_ca0106_pcm()
1322 substream = substream->next) { in snd_ca0106_pcm()
1324 &emu->pci->dev, in snd_ca0106_pcm()
1328 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; in snd_ca0106_pcm()
1330 substream = substream->next) { in snd_ca0106_pcm()
1332 &emu->pci->dev, in snd_ca0106_pcm()
1341 emu->pcm[device] = pcm; in snd_ca0106_pcm()
1371 { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */
1386 outl(0, chip->port + CA0106_INTE); in ca0106_init_chip()
1408 chip->spdif_str_bits[0] = chip->spdif_bits[0] = def_bits; in ca0106_init_chip()
1409 chip->spdif_str_bits[1] = chip->spdif_bits[1] = def_bits; in ca0106_init_chip()
1410 chip->spdif_str_bits[2] = chip->spdif_bits[2] = def_bits; in ca0106_init_chip()
1411 chip->spdif_str_bits[3] = chip->spdif_bits[3] = def_bits; in ca0106_init_chip()
1414 snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]); in ca0106_init_chip()
1415 snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]); in ca0106_init_chip()
1416 snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]); in ca0106_init_chip()
1417 snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]); in ca0106_init_chip()
1423 outb(AC97_REC_GAIN, chip->port + CA0106_AC97ADDRESS); in ca0106_init_chip()
1424 outw(0x8000, chip->port + CA0106_AC97DATA); in ca0106_init_chip()
1442 chip->spdif_enable = 0; /* Set digital SPDIF output off */ in ca0106_init_chip()
1473 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1478 chip->capture_source = 3; in ca0106_init_chip()
1479 } else if (chip->details->ac97 == 1) { in ca0106_init_chip()
1484 chip->capture_source = 4; in ca0106_init_chip()
1490 chip->capture_source = 3; in ca0106_init_chip()
1493 if (chip->details->gpio_type == 2) { in ca0106_init_chip()
1498 outl(0x0, chip->port + CA0106_GPIO); in ca0106_init_chip()
1499 /* outl(0x00f0e000, chip->port + CA0106_GPIO); */ /* Analog */ in ca0106_init_chip()
1500 outl(0x005f5301, chip->port + CA0106_GPIO); /* Analog */ in ca0106_init_chip()
1501 } else if (chip->details->gpio_type == 1) { in ca0106_init_chip()
1506 outl(0x0, chip->port + CA0106_GPIO); in ca0106_init_chip()
1507 /* outl(0x00f0e000, chip->port + CA0106_GPIO); */ /* Analog */ in ca0106_init_chip()
1508 outl(0x005f5301, chip->port + CA0106_GPIO); /* Analog */ in ca0106_init_chip()
1510 outl(0x0, chip->port + CA0106_GPIO); in ca0106_init_chip()
1511 outl(0x005f03a3, chip->port + CA0106_GPIO); /* Analog */ in ca0106_init_chip()
1512 /* outl(0x005f02a2, chip->port + CA0106_GPIO); */ /* SPDIF */ in ca0106_init_chip()
1516 /* outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); */ in ca0106_init_chip()
1518 /* outl(0x00001409, chip->port + CA0106_HCFG); */ in ca0106_init_chip()
1519 /* outl(0x00000009, chip->port + CA0106_HCFG); */ in ca0106_init_chip()
1521 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port + CA0106_HCFG); in ca0106_init_chip()
1523 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1528 /* dev_dbg(emu->card->dev, "I2C:array size=0x%x\n", size); */ in ca0106_init_chip()
1533 chip->i2c_capture_volume[n][0] = 0xcf; in ca0106_init_chip()
1534 chip->i2c_capture_volume[n][1] = 0xcf; in ca0106_init_chip()
1536 chip->i2c_capture_source = 2; /* Line in */ in ca0106_init_chip()
1537 /* Enable Line-in capture. MIC in currently untested. */ in ca0106_init_chip()
1541 if (chip->details->spi_dac) { in ca0106_init_chip()
1550 if (reg < ARRAY_SIZE(chip->spi_dac_reg)) in ca0106_init_chip()
1551 chip->spi_dac_reg[reg] = spi_dac_init[n]; in ca0106_init_chip()
1563 outl(0, chip->port + CA0106_INTE); in ca0106_stop_chip()
1567 /* outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); */ in ca0106_stop_chip()
1568 outl(0, chip->port + CA0106_HCFG); in ca0106_stop_chip()
1571 * So we can fix: snd-malloc: Memory leak? pages not freed = 8 in ca0106_stop_chip()
1578 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_create()
1585 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { in snd_ca0106_create()
1586 dev_err(card->dev, "error to set 32bit mask DMA\n"); in snd_ca0106_create()
1587 return -ENXIO; in snd_ca0106_create()
1590 chip->card = card; in snd_ca0106_create()
1591 chip->pci = pci; in snd_ca0106_create()
1592 chip->irq = -1; in snd_ca0106_create()
1594 spin_lock_init(&chip->emu_lock); in snd_ca0106_create()
1599 chip->port = pci_resource_start(pci, 0); in snd_ca0106_create()
1601 if (devm_request_irq(&pci->dev, pci->irq, snd_ca0106_interrupt, in snd_ca0106_create()
1603 dev_err(card->dev, "cannot grab irq\n"); in snd_ca0106_create()
1604 return -EBUSY; in snd_ca0106_create()
1606 chip->irq = pci->irq; in snd_ca0106_create()
1607 card->sync_irq = chip->irq; in snd_ca0106_create()
1610 chip->buffer = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 1024); in snd_ca0106_create()
1611 if (!chip->buffer) in snd_ca0106_create()
1612 return -ENOMEM; in snd_ca0106_create()
1615 /* read serial */ in snd_ca0106_create()
1616 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); in snd_ca0106_create()
1617 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); in snd_ca0106_create()
1618 dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", in snd_ca0106_create()
1619 chip->model, pci->revision, chip->serial); in snd_ca0106_create()
1620 strcpy(card->driver, "CA0106"); in snd_ca0106_create()
1621 strcpy(card->shortname, "CA0106"); in snd_ca0106_create()
1623 for (c = ca0106_chip_details; c->serial; c++) { in snd_ca0106_create()
1625 if (c->serial == subsystem[dev]) in snd_ca0106_create()
1627 } else if (c->serial == chip->serial) in snd_ca0106_create()
1630 chip->details = c; in snd_ca0106_create()
1632 dev_info(card->dev, "Sound card name=%s, " in snd_ca0106_create()
1634 c->name, chip->serial, subsystem[dev]); in snd_ca0106_create()
1637 sprintf(card->longname, "%s at 0x%lx irq %i", in snd_ca0106_create()
1638 c->name, chip->port, chip->irq); in snd_ca0106_create()
1645 static void ca0106_midi_interrupt_enable(struct snd_ca_midi *midi, int intr) in ca0106_midi_interrupt_enable() argument
1647 snd_ca0106_intr_enable((struct snd_ca0106 *)(midi->dev_id), intr); in ca0106_midi_interrupt_enable()
1650 static void ca0106_midi_interrupt_disable(struct snd_ca_midi *midi, int intr) in ca0106_midi_interrupt_disable() argument
1652 snd_ca0106_intr_disable((struct snd_ca0106 *)(midi->dev_id), intr); in ca0106_midi_interrupt_disable()
1655 static unsigned char ca0106_midi_read(struct snd_ca_midi *midi, int idx) in ca0106_midi_read() argument
1657 return (unsigned char)snd_ca0106_ptr_read((struct snd_ca0106 *)(midi->dev_id), in ca0106_midi_read()
1658 midi->port + idx, 0); in ca0106_midi_read()
1661 static void ca0106_midi_write(struct snd_ca_midi *midi, int data, int idx) in ca0106_midi_write() argument
1663 snd_ca0106_ptr_write((struct snd_ca0106 *)(midi->dev_id), midi->port + idx, 0, data); in ca0106_midi_write()
1668 return ((struct snd_ca0106 *)dev_id)->card; in ca0106_dev_id_card()
1673 return ((struct snd_ca0106 *)dev_id)->port; in ca0106_dev_id_port()
1678 struct snd_ca_midi *midi; in snd_ca0106_midi() local
1683 name = "CA0106 MPU-401 (UART) B"; in snd_ca0106_midi()
1684 midi = &chip->midi2; in snd_ca0106_midi()
1685 midi->tx_enable = INTE_MIDI_TX_B; in snd_ca0106_midi()
1686 midi->rx_enable = INTE_MIDI_RX_B; in snd_ca0106_midi()
1687 midi->ipr_tx = IPR_MIDI_TX_B; in snd_ca0106_midi()
1688 midi->ipr_rx = IPR_MIDI_RX_B; in snd_ca0106_midi()
1689 midi->port = MIDI_UART_B_DATA; in snd_ca0106_midi()
1691 name = "CA0106 MPU-401 (UART)"; in snd_ca0106_midi()
1692 midi = &chip->midi; in snd_ca0106_midi()
1693 midi->tx_enable = INTE_MIDI_TX_A; in snd_ca0106_midi()
1694 midi->rx_enable = INTE_MIDI_TX_B; in snd_ca0106_midi()
1695 midi->ipr_tx = IPR_MIDI_TX_A; in snd_ca0106_midi()
1696 midi->ipr_rx = IPR_MIDI_RX_A; in snd_ca0106_midi()
1697 midi->port = MIDI_UART_A_DATA; in snd_ca0106_midi()
1700 midi->reset = CA0106_MPU401_RESET; in snd_ca0106_midi()
1701 midi->enter_uart = CA0106_MPU401_ENTER_UART; in snd_ca0106_midi()
1702 midi->ack = CA0106_MPU401_ACK; in snd_ca0106_midi()
1704 midi->input_avail = CA0106_MIDI_INPUT_AVAIL; in snd_ca0106_midi()
1705 midi->output_ready = CA0106_MIDI_OUTPUT_READY; in snd_ca0106_midi()
1707 midi->channel = channel; in snd_ca0106_midi()
1709 midi->interrupt_enable = ca0106_midi_interrupt_enable; in snd_ca0106_midi()
1710 midi->interrupt_disable = ca0106_midi_interrupt_disable; in snd_ca0106_midi()
1712 midi->read = ca0106_midi_read; in snd_ca0106_midi()
1713 midi->write = ca0106_midi_write; in snd_ca0106_midi()
1715 midi->get_dev_id_card = ca0106_dev_id_card; in snd_ca0106_midi()
1716 midi->get_dev_id_port = ca0106_dev_id_port; in snd_ca0106_midi()
1718 midi->dev_id = chip; in snd_ca0106_midi()
1720 err = ca_midi_init(chip, midi, 0, name); in snd_ca0106_midi()
1737 return -ENODEV; in __snd_ca0106_probe()
1740 return -ENOENT; in __snd_ca0106_probe()
1743 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_ca0106_probe()
1747 chip = card->private_data; in __snd_ca0106_probe()
1752 card->private_free = snd_ca0106_free; in __snd_ca0106_probe()
1760 if (chip->details->ac97 == 1) { in __snd_ca0106_probe()
1770 dev_dbg(card->dev, "probe for MIDI channel A ..."); in __snd_ca0106_probe()
1774 dev_dbg(card->dev, " done.\n"); in __snd_ca0106_probe()
1792 return snd_card_free_on_error(&pci->dev, __snd_ca0106_probe(pci, pci_id)); in snd_ca0106_probe()
1799 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_suspend()
1802 if (chip->details->ac97) in snd_ca0106_suspend()
1803 snd_ac97_suspend(chip->ac97); in snd_ca0106_suspend()
1813 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_resume()
1818 if (chip->details->ac97) in snd_ca0106_resume()
1819 snd_ac97_resume(chip->ac97); in snd_ca0106_resume()
1821 if (chip->details->spi_dac) { in snd_ca0106_resume()
1822 for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++) in snd_ca0106_resume()
1823 snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]); in snd_ca0106_resume()