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>");
160 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
165 { .serial = 0x10131102,
166 .name = "X-Fi Extreme Audio [SBxxxx]",
169 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
172 * CTRL:CA0111-WTLF
174 * DAC: CS4382-KQZ
179 * Not-Tested:
183 { .serial = 0x10121102,
184 .name = "X-Fi Extreme Audio [SB0790]",
189 { .serial = 0x10021102,
193 { .serial = 0x10051102,
197 { .serial = 0x10061102,
202 { .serial = 0x10071102,
208 * CTRL:CA0106-DAT
212 { .serial = 0x100a1102,
219 * CTRL:CA0106-DAT
223 { .serial = 0x10111102,
230 * Not-Tested: Capture
232 { .serial = 0x10041102,
240 * CTRL:CA0106-DAT
242 * DAC: CS4382-KQZ
244 { .serial = 0x10091462,
249 { .serial = 0x10091102,
254 /* Giga-byte GA-G1975X mobo
258 { .serial = 0x1458a006,
259 .name = "Giga-byte GA-G1975X",
263 * Sound Blaster Live! 24-bit EAX
264 * high-definition 7.1 audio processor".
267 { .serial = 0x30381297,
272 * Sound Blaster Live! 24-bit EAX
273 * high-definition 7.1 audio processor".
276 { .serial = 0x30411297,
280 { .serial = 0,
298 .buffer_bytes_max = ((65536 - 64) * 8),
300 .period_bytes_max = (65536 - 64),
324 .buffer_bytes_max = 65536 - 128,
326 .period_bytes_max = 32768 - 64,
341 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ptr_read()
342 outl(regptr, emu->port + PTR); in snd_ca0106_ptr_read()
343 val = inl(emu->port + DATA); in snd_ca0106_ptr_read()
344 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ptr_read()
358 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ptr_write()
359 outl(regptr, emu->port + PTR); in snd_ca0106_ptr_write()
360 outl(data, emu->port + DATA); in snd_ca0106_ptr_write()
361 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ptr_write()
406 dev_err(emu->card->dev, "i2c_write: invalid values.\n"); in snd_ca0106_i2c_write()
407 return -EINVAL; in snd_ca0106_i2c_write()
412 dev_dbg(emu->card->dev, "I2C-write:reg=0x%x, value=0x%x\n", reg, value); in snd_ca0106_i2c_write()
431 /*dev_dbg(emu->card->dev, "I2C:status=0x%x\n", status);*/ in snd_ca0106_i2c_write()
445 dev_err(emu->card->dev, "Writing to ADC failed!\n"); in snd_ca0106_i2c_write()
446 return -EINVAL; in snd_ca0106_i2c_write()
458 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_intr_enable()
459 intr_enable = inl(emu->port + INTE) | intrenb; in snd_ca0106_intr_enable()
460 outl(intr_enable, emu->port + INTE); in snd_ca0106_intr_enable()
461 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_intr_enable()
469 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_intr_disable()
470 intr_enable = inl(emu->port + INTE) & ~intrenb; in snd_ca0106_intr_disable()
471 outl(intr_enable, emu->port + INTE); in snd_ca0106_intr_disable()
472 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_intr_disable()
478 kfree(runtime->private_data); in snd_ca0106_pcm_free_substream()
498 if (chip->spdif_str_bits[idx] != chip->spdif_bits[idx]) { in restore_spdif_bits()
499 chip->spdif_str_bits[idx] = chip->spdif_bits[idx]; in restore_spdif_bits()
501 chip->spdif_str_bits[idx]); in restore_spdif_bits()
511 return (details->spi_dac & 0xf000) >> (4 * 3); in snd_ca0106_channel_dac()
513 return (details->spi_dac & 0x0f00) >> (4 * 2); in snd_ca0106_channel_dac()
515 return (details->spi_dac & 0x00f0) >> (4 * 1); in snd_ca0106_channel_dac()
517 return (details->spi_dac & 0x000f) >> (4 * 0); in snd_ca0106_channel_dac()
519 dev_dbg(chip->card->dev, "ca0106: unknown channel_id %d\n", in snd_ca0106_channel_dac()
528 if (chip->details->spi_dac) { in snd_ca0106_pcm_power_dac()
529 const int dac = snd_ca0106_channel_dac(chip, chip->details, in snd_ca0106_pcm_power_dac()
536 chip->spi_dac_reg[reg] &= ~bit; in snd_ca0106_pcm_power_dac()
539 chip->spi_dac_reg[reg] |= bit; in snd_ca0106_pcm_power_dac()
540 if (snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]) != 0) in snd_ca0106_pcm_power_dac()
541 return -ENXIO; in snd_ca0106_pcm_power_dac()
551 struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); in snd_ca0106_pcm_open_playback_channel()
553 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_open_playback_channel()
559 return -ENOMEM; in snd_ca0106_pcm_open_playback_channel()
560 epcm->emu = chip; in snd_ca0106_pcm_open_playback_channel()
561 epcm->substream = substream; in snd_ca0106_pcm_open_playback_channel()
562 epcm->channel_id=channel_id; in snd_ca0106_pcm_open_playback_channel()
564 runtime->private_data = epcm; in snd_ca0106_pcm_open_playback_channel()
565 runtime->private_free = snd_ca0106_pcm_free_substream; in snd_ca0106_pcm_open_playback_channel()
567 runtime->hw = snd_ca0106_playback_hw; in snd_ca0106_pcm_open_playback_channel()
569 channel->emu = chip; in snd_ca0106_pcm_open_playback_channel()
570 channel->number = channel_id; in snd_ca0106_pcm_open_playback_channel()
572 channel->use = 1; in snd_ca0106_pcm_open_playback_channel()
574 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", in snd_ca0106_pcm_open_playback_channel()
577 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; in snd_ca0106_pcm_open_playback_channel()
578 channel->epcm = epcm; in snd_ca0106_pcm_open_playback_channel()
601 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_close_playback()
602 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_close_playback()
603 chip->playback_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_playback()
605 restore_spdif_bits(chip, epcm->channel_id); in snd_ca0106_pcm_close_playback()
608 if (epcm->channel_id != PCM_FRONT_CHANNEL) { in snd_ca0106_pcm_close_playback()
610 err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0); in snd_ca0106_pcm_close_playback()
644 struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); in snd_ca0106_pcm_open_capture_channel()
646 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_open_capture_channel()
651 return -ENOMEM; in snd_ca0106_pcm_open_capture_channel()
653 epcm->emu = chip; in snd_ca0106_pcm_open_capture_channel()
654 epcm->substream = substream; in snd_ca0106_pcm_open_capture_channel()
655 epcm->channel_id=channel_id; in snd_ca0106_pcm_open_capture_channel()
657 runtime->private_data = epcm; in snd_ca0106_pcm_open_capture_channel()
658 runtime->private_free = snd_ca0106_pcm_free_substream; in snd_ca0106_pcm_open_capture_channel()
660 runtime->hw = snd_ca0106_capture_hw; in snd_ca0106_pcm_open_capture_channel()
662 channel->emu = chip; in snd_ca0106_pcm_open_capture_channel()
663 channel->number = channel_id; in snd_ca0106_pcm_open_capture_channel()
665 channel->use = 1; in snd_ca0106_pcm_open_capture_channel()
667 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", in snd_ca0106_pcm_open_capture_channel()
670 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; in snd_ca0106_pcm_open_capture_channel()
671 channel->epcm = epcm; in snd_ca0106_pcm_open_capture_channel()
684 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_close_capture()
685 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_close_capture()
686 chip->capture_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_capture()
715 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_prepare_playback()
716 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_prepare_playback()
717 int channel = epcm->channel_id; in snd_ca0106_pcm_prepare_playback()
718 u32 *table_base = (u32 *)(emu->buffer.area+(8*16*channel)); in snd_ca0106_pcm_prepare_playback()
719 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); in snd_ca0106_pcm_prepare_playback()
733 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
737 channel, runtime->rate, runtime->format, in snd_ca0106_pcm_prepare_playback()
738 runtime->channels, runtime->buffer_size, in snd_ca0106_pcm_prepare_playback()
739 runtime->period_size, runtime->periods, in snd_ca0106_pcm_prepare_playback()
741 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
743 runtime->dma_addr, runtime->dma_area, table_base); in snd_ca0106_pcm_prepare_playback()
744 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_playback()
746 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); in snd_ca0106_pcm_prepare_playback()
751 switch (runtime->rate) { in snd_ca0106_pcm_prepare_playback()
775 switch (runtime->format) { in snd_ca0106_pcm_prepare_playback()
786 hcfg = inl(emu->port + HCFG) ; in snd_ca0106_pcm_prepare_playback()
788 outl(hcfg, emu->port + HCFG); in snd_ca0106_pcm_prepare_playback()
796 /* FIXME: Check emu->buffer.size before actually writing to it. */ in snd_ca0106_pcm_prepare_playback()
797 for(i=0; i < runtime->periods; i++) { in snd_ca0106_pcm_prepare_playback()
798 table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); in snd_ca0106_pcm_prepare_playback()
802 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer.addr+(8*16*channel)); in snd_ca0106_pcm_prepare_playback()
803 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); in snd_ca0106_pcm_prepare_playback()
805 snd_ca0106_ptr_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); in snd_ca0106_pcm_prepare_playback()
806 …snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_… in snd_ca0106_pcm_prepare_playback()
828 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_prepare_capture()
829 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_prepare_capture()
830 int channel = epcm->channel_id; in snd_ca0106_pcm_prepare_capture()
840 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
844 channel, runtime->rate, runtime->format, in snd_ca0106_pcm_prepare_capture()
845 runtime->channels, runtime->buffer_size, in snd_ca0106_pcm_prepare_capture()
846 runtime->period_size, runtime->periods, in snd_ca0106_pcm_prepare_capture()
848 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
850 runtime->dma_addr, runtime->dma_area, table_base); in snd_ca0106_pcm_prepare_capture()
851 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
853 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); in snd_ca0106_pcm_prepare_capture()
856 switch (runtime->rate) { in snd_ca0106_pcm_prepare_capture()
877 switch (runtime->format) { in snd_ca0106_pcm_prepare_capture()
888 hcfg = inl(emu->port + HCFG) ; in snd_ca0106_pcm_prepare_capture()
890 outl(hcfg, emu->port + HCFG); in snd_ca0106_pcm_prepare_capture()
894 if (emu->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ in snd_ca0106_pcm_prepare_capture()
900 dev_dbg(emu->card->dev, in snd_ca0106_pcm_prepare_capture()
903 channel, runtime->rate, runtime->format, runtime->channels, in snd_ca0106_pcm_prepare_capture()
904 runtime->buffer_size, runtime->period_size, in snd_ca0106_pcm_prepare_capture()
908 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); in snd_ca0106_pcm_prepare_capture()
909 …snd_ca0106_ptr_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_s… in snd_ca0106_pcm_prepare_capture()
943 s->stream != SNDRV_PCM_STREAM_PLAYBACK) in snd_ca0106_pcm_trigger_playback()
945 runtime = s->runtime; in snd_ca0106_pcm_trigger_playback()
946 epcm = runtime->private_data; in snd_ca0106_pcm_trigger_playback()
947 channel = epcm->channel_id; in snd_ca0106_pcm_trigger_playback()
948 /* dev_dbg(emu->card->dev, "channel=%d\n", channel); */ in snd_ca0106_pcm_trigger_playback()
949 epcm->running = running; in snd_ca0106_pcm_trigger_playback()
954 /* dev_dbg(emu->card->dev, "basic=0x%x, extended=0x%x\n",basic, extended); */ in snd_ca0106_pcm_trigger_playback()
976 result = -EINVAL; in snd_ca0106_pcm_trigger_playback()
987 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_trigger_capture()
988 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_trigger_capture()
989 int channel = epcm->channel_id; in snd_ca0106_pcm_trigger_capture()
996 epcm->running = 1; in snd_ca0106_pcm_trigger_capture()
1001 epcm->running = 0; in snd_ca0106_pcm_trigger_capture()
1004 result = -EINVAL; in snd_ca0106_pcm_trigger_capture()
1015 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_pointer_playback()
1016 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_pointer_playback()
1018 int channel = epcm->channel_id; in snd_ca0106_pcm_pointer_playback()
1021 if (!epcm->running) in snd_ca0106_pcm_pointer_playback()
1024 prev_ptr = -1; in snd_ca0106_pcm_pointer_playback()
1027 ptr = (ptr >> 3) * runtime->period_size; in snd_ca0106_pcm_pointer_playback()
1030 if (ptr >= runtime->buffer_size) in snd_ca0106_pcm_pointer_playback()
1031 ptr -= runtime->buffer_size; in snd_ca0106_pcm_pointer_playback()
1035 } while (--timeout); in snd_ca0106_pcm_pointer_playback()
1036 dev_warn(emu->card->dev, "ca0106: unstable DMA pointer!\n"); in snd_ca0106_pcm_pointer_playback()
1045 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ca0106_pcm_pointer_capture()
1046 struct snd_ca0106_pcm *epcm = runtime->private_data; in snd_ca0106_pcm_pointer_capture()
1048 int channel = epcm->channel_id; in snd_ca0106_pcm_pointer_capture()
1050 if (!epcm->running) in snd_ca0106_pcm_pointer_capture()
1056 if (ptr >= runtime->buffer_size) in snd_ca0106_pcm_pointer_capture()
1057 ptr -= runtime->buffer_size; in snd_ca0106_pcm_pointer_capture()
1059 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " in snd_ca0106_pcm_pointer_capture()
1061 ptr1, ptr2, ptr, (int)runtime->buffer_size, in snd_ca0106_pcm_pointer_capture()
1062 (int)runtime->period_size, (int)runtime->frame_bits, in snd_ca0106_pcm_pointer_capture()
1063 (int)runtime->rate); in snd_ca0106_pcm_pointer_capture()
1137 struct snd_ca0106 *emu = ac97->private_data; in snd_ca0106_ac97_read()
1141 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ac97_read()
1142 outb(reg, emu->port + AC97ADDRESS); in snd_ca0106_ac97_read()
1143 val = inw(emu->port + AC97DATA); in snd_ca0106_ac97_read()
1144 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ac97_read()
1151 struct snd_ca0106 *emu = ac97->private_data; in snd_ca0106_ac97_write()
1154 spin_lock_irqsave(&emu->emu_lock, flags); in snd_ca0106_ac97_write()
1155 outb(reg, emu->port + AC97ADDRESS); in snd_ca0106_ac97_write()
1156 outw(val, emu->port + AC97DATA); in snd_ca0106_ac97_write()
1157 spin_unlock_irqrestore(&emu->emu_lock, flags); in snd_ca0106_ac97_write()
1170 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) in snd_ca0106_ac97()
1172 pbus->no_vra = 1; /* we don't need VRA */ in snd_ca0106_ac97()
1177 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_ca0106_ac97()
1184 if (chip->res_port != NULL) { in snd_ca0106_free()
1188 if (chip->irq >= 0) in snd_ca0106_free()
1189 free_irq(chip->irq, chip); in snd_ca0106_free()
1192 if (chip->buffer.area) in snd_ca0106_free()
1193 snd_dma_free_pages(&chip->buffer); in snd_ca0106_free()
1197 release_and_free_resource(chip->res_port); in snd_ca0106_free()
1199 pci_disable_device(chip->pci); in snd_ca0106_free()
1206 struct snd_ca0106 *chip = device->device_data; in snd_ca0106_dev_free()
1220 status = inl(chip->port + IPR); in snd_ca0106_interrupt()
1226 dev_dbg(emu->card->dev, "interrupt status = 0x%08x, stat76=0x%08x\n", in snd_ca0106_interrupt()
1228 dev_dbg(emu->card->dev, "ptr=0x%08x\n", in snd_ca0106_interrupt()
1233 pchannel = &(chip->playback_channels[i]); in snd_ca0106_interrupt()
1236 if(pchannel->use) { in snd_ca0106_interrupt()
1237 snd_pcm_period_elapsed(pchannel->epcm->substream); in snd_ca0106_interrupt()
1238 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */ in snd_ca0106_interrupt()
1242 dev_dbg(emu->card->dev, "channel=%p\n", pchannel); in snd_ca0106_interrupt()
1243 …dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->… in snd_ca0106_interrupt()
1249 pchannel = &(chip->capture_channels[i]); in snd_ca0106_interrupt()
1252 if(pchannel->use) { in snd_ca0106_interrupt()
1253 snd_pcm_period_elapsed(pchannel->epcm->substream); in snd_ca0106_interrupt()
1254 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */ in snd_ca0106_interrupt()
1258 dev_dbg(emu->card->dev, "channel=%p\n", pchannel); in snd_ca0106_interrupt()
1259 …dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->… in snd_ca0106_interrupt()
1266 if (chip->midi.dev_id && in snd_ca0106_interrupt()
1267 (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { in snd_ca0106_interrupt()
1268 if (chip->midi.interrupt) in snd_ca0106_interrupt()
1269 chip->midi.interrupt(&chip->midi, status); in snd_ca0106_interrupt()
1271 chip->midi.interrupt_disable(&chip->midi, chip->midi.tx_enable | chip->midi.rx_enable); in snd_ca0106_interrupt()
1275 outl(status, chip->port+IPR); in snd_ca0106_interrupt()
1305 err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm); in snd_ca0106_pcm()
1309 pcm->private_data = emu; in snd_ca0106_pcm()
1334 pcm->info_flags = 0; in snd_ca0106_pcm()
1335 strcpy(pcm->name, "CA0106"); in snd_ca0106_pcm()
1337 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in snd_ca0106_pcm()
1339 substream = substream->next) { in snd_ca0106_pcm()
1341 &emu->pci->dev, in snd_ca0106_pcm()
1345 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; in snd_ca0106_pcm()
1347 substream = substream->next) { in snd_ca0106_pcm()
1349 &emu->pci->dev, in snd_ca0106_pcm()
1358 emu->pcm[device] = pcm; in snd_ca0106_pcm()
1388 { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */
1403 outl(0, chip->port + INTE); in ca0106_init_chip()
1425 chip->spdif_str_bits[0] = chip->spdif_bits[0] = def_bits; in ca0106_init_chip()
1426 chip->spdif_str_bits[1] = chip->spdif_bits[1] = def_bits; in ca0106_init_chip()
1427 chip->spdif_str_bits[2] = chip->spdif_bits[2] = def_bits; in ca0106_init_chip()
1428 chip->spdif_str_bits[3] = chip->spdif_bits[3] = def_bits; in ca0106_init_chip()
1431 snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]); in ca0106_init_chip()
1432 snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]); in ca0106_init_chip()
1433 snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]); in ca0106_init_chip()
1434 snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]); in ca0106_init_chip()
1440 outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); in ca0106_init_chip()
1441 outw(0x8000, chip->port + AC97DATA); in ca0106_init_chip()
1459 chip->spdif_enable = 0; /* Set digital SPDIF output off */ in ca0106_init_chip()
1490 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1495 chip->capture_source = 3; in ca0106_init_chip()
1496 } else if (chip->details->ac97 == 1) { in ca0106_init_chip()
1501 chip->capture_source = 4; in ca0106_init_chip()
1507 chip->capture_source = 3; in ca0106_init_chip()
1510 if (chip->details->gpio_type == 2) { in ca0106_init_chip()
1515 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1516 /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */ in ca0106_init_chip()
1517 outl(0x005f5301, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1518 } else if (chip->details->gpio_type == 1) { in ca0106_init_chip()
1523 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1524 /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */ in ca0106_init_chip()
1525 outl(0x005f5301, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1527 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1528 outl(0x005f03a3, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1529 /* outl(0x005f02a2, chip->port+GPIO); */ /* SPDIF */ in ca0106_init_chip()
1533 /* outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); */ in ca0106_init_chip()
1535 /* outl(0x00001409, chip->port+HCFG); */ in ca0106_init_chip()
1536 /* outl(0x00000009, chip->port+HCFG); */ in ca0106_init_chip()
1538 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); in ca0106_init_chip()
1540 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1545 /* dev_dbg(emu->card->dev, "I2C:array size=0x%x\n", size); */ in ca0106_init_chip()
1550 chip->i2c_capture_volume[n][0] = 0xcf; in ca0106_init_chip()
1551 chip->i2c_capture_volume[n][1] = 0xcf; in ca0106_init_chip()
1553 chip->i2c_capture_source = 2; /* Line in */ in ca0106_init_chip()
1554 /* Enable Line-in capture. MIC in currently untested. */ in ca0106_init_chip()
1558 if (chip->details->spi_dac) { in ca0106_init_chip()
1567 if (reg < ARRAY_SIZE(chip->spi_dac_reg)) in ca0106_init_chip()
1568 chip->spi_dac_reg[reg] = spi_dac_init[n]; in ca0106_init_chip()
1580 outl(0, chip->port + INTE); in ca0106_stop_chip()
1584 /* outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); */ in ca0106_stop_chip()
1585 outl(0, chip->port + HCFG); in ca0106_stop_chip()
1588 * So we can fix: snd-malloc: Memory leak? pages not freed = 8 in ca0106_stop_chip()
1608 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 || in snd_ca0106_create()
1609 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) { in snd_ca0106_create()
1610 dev_err(card->dev, "error to set 32bit mask DMA\n"); in snd_ca0106_create()
1612 return -ENXIO; in snd_ca0106_create()
1618 return -ENOMEM; in snd_ca0106_create()
1621 chip->card = card; in snd_ca0106_create()
1622 chip->pci = pci; in snd_ca0106_create()
1623 chip->irq = -1; in snd_ca0106_create()
1625 spin_lock_init(&chip->emu_lock); in snd_ca0106_create()
1627 chip->port = pci_resource_start(pci, 0); in snd_ca0106_create()
1628 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106"); in snd_ca0106_create()
1629 if (!chip->res_port) { in snd_ca0106_create()
1631 dev_err(card->dev, "cannot allocate the port\n"); in snd_ca0106_create()
1632 return -EBUSY; in snd_ca0106_create()
1635 if (request_irq(pci->irq, snd_ca0106_interrupt, in snd_ca0106_create()
1638 dev_err(card->dev, "cannot grab irq\n"); in snd_ca0106_create()
1639 return -EBUSY; in snd_ca0106_create()
1641 chip->irq = pci->irq; in snd_ca0106_create()
1642 card->sync_irq = chip->irq; in snd_ca0106_create()
1645 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, in snd_ca0106_create()
1646 1024, &chip->buffer) < 0) { in snd_ca0106_create()
1648 return -ENOMEM; in snd_ca0106_create()
1652 /* read serial */ in snd_ca0106_create()
1653 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); in snd_ca0106_create()
1654 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); in snd_ca0106_create()
1655 dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", in snd_ca0106_create()
1656 chip->model, pci->revision, chip->serial); in snd_ca0106_create()
1657 strcpy(card->driver, "CA0106"); in snd_ca0106_create()
1658 strcpy(card->shortname, "CA0106"); in snd_ca0106_create()
1660 for (c = ca0106_chip_details; c->serial; c++) { in snd_ca0106_create()
1662 if (c->serial == subsystem[dev]) in snd_ca0106_create()
1664 } else if (c->serial == chip->serial) in snd_ca0106_create()
1667 chip->details = c; in snd_ca0106_create()
1669 dev_info(card->dev, "Sound card name=%s, " in snd_ca0106_create()
1671 c->name, chip->serial, subsystem[dev]); in snd_ca0106_create()
1674 sprintf(card->longname, "%s at 0x%lx irq %i", in snd_ca0106_create()
1675 c->name, chip->port, chip->irq); in snd_ca0106_create()
1689 static void ca0106_midi_interrupt_enable(struct snd_ca_midi *midi, int intr) in ca0106_midi_interrupt_enable() argument
1691 snd_ca0106_intr_enable((struct snd_ca0106 *)(midi->dev_id), intr); in ca0106_midi_interrupt_enable()
1694 static void ca0106_midi_interrupt_disable(struct snd_ca_midi *midi, int intr) in ca0106_midi_interrupt_disable() argument
1696 snd_ca0106_intr_disable((struct snd_ca0106 *)(midi->dev_id), intr); in ca0106_midi_interrupt_disable()
1699 static unsigned char ca0106_midi_read(struct snd_ca_midi *midi, int idx) in ca0106_midi_read() argument
1701 return (unsigned char)snd_ca0106_ptr_read((struct snd_ca0106 *)(midi->dev_id), in ca0106_midi_read()
1702 midi->port + idx, 0); in ca0106_midi_read()
1705 static void ca0106_midi_write(struct snd_ca_midi *midi, int data, int idx) in ca0106_midi_write() argument
1707 snd_ca0106_ptr_write((struct snd_ca0106 *)(midi->dev_id), midi->port + idx, 0, data); in ca0106_midi_write()
1712 return ((struct snd_ca0106 *)dev_id)->card; in ca0106_dev_id_card()
1717 return ((struct snd_ca0106 *)dev_id)->port; in ca0106_dev_id_port()
1722 struct snd_ca_midi *midi; in snd_ca0106_midi() local
1727 name = "CA0106 MPU-401 (UART) B"; in snd_ca0106_midi()
1728 midi = &chip->midi2; in snd_ca0106_midi()
1729 midi->tx_enable = INTE_MIDI_TX_B; in snd_ca0106_midi()
1730 midi->rx_enable = INTE_MIDI_RX_B; in snd_ca0106_midi()
1731 midi->ipr_tx = IPR_MIDI_TX_B; in snd_ca0106_midi()
1732 midi->ipr_rx = IPR_MIDI_RX_B; in snd_ca0106_midi()
1733 midi->port = MIDI_UART_B_DATA; in snd_ca0106_midi()
1735 name = "CA0106 MPU-401 (UART)"; in snd_ca0106_midi()
1736 midi = &chip->midi; in snd_ca0106_midi()
1737 midi->tx_enable = INTE_MIDI_TX_A; in snd_ca0106_midi()
1738 midi->rx_enable = INTE_MIDI_TX_B; in snd_ca0106_midi()
1739 midi->ipr_tx = IPR_MIDI_TX_A; in snd_ca0106_midi()
1740 midi->ipr_rx = IPR_MIDI_RX_A; in snd_ca0106_midi()
1741 midi->port = MIDI_UART_A_DATA; in snd_ca0106_midi()
1744 midi->reset = CA0106_MPU401_RESET; in snd_ca0106_midi()
1745 midi->enter_uart = CA0106_MPU401_ENTER_UART; in snd_ca0106_midi()
1746 midi->ack = CA0106_MPU401_ACK; in snd_ca0106_midi()
1748 midi->input_avail = CA0106_MIDI_INPUT_AVAIL; in snd_ca0106_midi()
1749 midi->output_ready = CA0106_MIDI_OUTPUT_READY; in snd_ca0106_midi()
1751 midi->channel = channel; in snd_ca0106_midi()
1753 midi->interrupt_enable = ca0106_midi_interrupt_enable; in snd_ca0106_midi()
1754 midi->interrupt_disable = ca0106_midi_interrupt_disable; in snd_ca0106_midi()
1756 midi->read = ca0106_midi_read; in snd_ca0106_midi()
1757 midi->write = ca0106_midi_write; in snd_ca0106_midi()
1759 midi->get_dev_id_card = ca0106_dev_id_card; in snd_ca0106_midi()
1760 midi->get_dev_id_port = ca0106_dev_id_port; in snd_ca0106_midi()
1762 midi->dev_id = chip; in snd_ca0106_midi()
1764 if ((err = ca_midi_init(chip, midi, 0, name)) < 0) in snd_ca0106_midi()
1780 return -ENODEV; in snd_ca0106_probe()
1783 return -ENOENT; in snd_ca0106_probe()
1786 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in snd_ca0106_probe()
1794 card->private_data = chip; in snd_ca0106_probe()
1802 if (chip->details->ac97 == 1) { in snd_ca0106_probe()
1812 dev_dbg(card->dev, "probe for MIDI channel A ..."); in snd_ca0106_probe()
1816 dev_dbg(card->dev, " done.\n"); in snd_ca0106_probe()
1844 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_suspend()
1847 if (chip->details->ac97) in snd_ca0106_suspend()
1848 snd_ac97_suspend(chip->ac97); in snd_ca0106_suspend()
1858 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_resume()
1863 if (chip->details->ac97) in snd_ca0106_resume()
1864 snd_ac97_resume(chip->ac97); in snd_ca0106_resume()
1866 if (chip->details->spi_dac) { in snd_ca0106_resume()
1867 for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++) in snd_ca0106_resume()
1868 snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]); in snd_ca0106_resume()