Lines Matching refs:chip
510 static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) in restore_spdif_bits() argument
512 if (chip->spdif_str_bits[idx] != chip->spdif_bits[idx]) { in restore_spdif_bits()
513 chip->spdif_str_bits[idx] = chip->spdif_bits[idx]; in restore_spdif_bits()
514 snd_ca0106_ptr_write(chip, SPCS0 + idx, 0, in restore_spdif_bits()
515 chip->spdif_str_bits[idx]); in restore_spdif_bits()
519 static int snd_ca0106_channel_dac(struct snd_ca0106 *chip, in snd_ca0106_channel_dac() argument
533 dev_dbg(chip->card->dev, "ca0106: unknown channel_id %d\n", in snd_ca0106_channel_dac()
539 static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id, in snd_ca0106_pcm_power_dac() argument
542 if (chip->details->spi_dac) { in snd_ca0106_pcm_power_dac()
543 const int dac = snd_ca0106_channel_dac(chip, chip->details, in snd_ca0106_pcm_power_dac()
550 chip->spi_dac_reg[reg] &= ~bit; in snd_ca0106_pcm_power_dac()
553 chip->spi_dac_reg[reg] |= bit; in snd_ca0106_pcm_power_dac()
554 return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); in snd_ca0106_pcm_power_dac()
563 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); in snd_ca0106_pcm_open_playback_channel() local
564 struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); in snd_ca0106_pcm_open_playback_channel()
573 epcm->emu = chip; in snd_ca0106_pcm_open_playback_channel()
582 channel->emu = chip; in snd_ca0106_pcm_open_playback_channel()
600 err = snd_ca0106_pcm_power_dac(chip, channel_id, 1); in snd_ca0106_pcm_open_playback_channel()
605 restore_spdif_bits(chip, channel_id); in snd_ca0106_pcm_open_playback_channel()
613 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); in snd_ca0106_pcm_close_playback() local
616 chip->playback_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_playback()
618 restore_spdif_bits(chip, epcm->channel_id); in snd_ca0106_pcm_close_playback()
623 err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0); in snd_ca0106_pcm_close_playback()
656 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); in snd_ca0106_pcm_open_capture_channel() local
657 struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); in snd_ca0106_pcm_open_capture_channel()
664 dev_err(chip->card->dev, in snd_ca0106_pcm_open_capture_channel()
668 epcm->emu = chip; in snd_ca0106_pcm_open_capture_channel()
677 channel->emu = chip; in snd_ca0106_pcm_open_capture_channel()
698 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); in snd_ca0106_pcm_close_capture() local
701 chip->capture_channels[epcm->channel_id].use = 0; in snd_ca0106_pcm_close_capture()
1227 static int snd_ca0106_ac97(struct snd_ca0106 *chip) in snd_ca0106_ac97() argument
1237 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) in snd_ca0106_ac97()
1242 ac97.private_data = chip; in snd_ca0106_ac97()
1244 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_ca0106_ac97()
1247 static void ca0106_stop_chip(struct snd_ca0106 *chip);
1249 static int snd_ca0106_free(struct snd_ca0106 *chip) in snd_ca0106_free() argument
1251 if (chip->res_port != NULL) { in snd_ca0106_free()
1253 ca0106_stop_chip(chip); in snd_ca0106_free()
1255 if (chip->irq >= 0) in snd_ca0106_free()
1256 free_irq(chip->irq, chip); in snd_ca0106_free()
1259 if (chip->buffer.area) in snd_ca0106_free()
1260 snd_dma_free_pages(&chip->buffer); in snd_ca0106_free()
1264 release_and_free_resource(chip->res_port); in snd_ca0106_free()
1266 pci_disable_device(chip->pci); in snd_ca0106_free()
1267 kfree(chip); in snd_ca0106_free()
1273 struct snd_ca0106 *chip = device->device_data; in snd_ca0106_dev_free() local
1274 return snd_ca0106_free(chip); in snd_ca0106_dev_free()
1281 struct snd_ca0106 *chip = dev_id; in snd_ca0106_interrupt() local
1287 status = inl(chip->port + IPR); in snd_ca0106_interrupt()
1291 stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0); in snd_ca0106_interrupt()
1300 pchannel = &(chip->playback_channels[i]); in snd_ca0106_interrupt()
1316 pchannel = &(chip->capture_channels[i]); in snd_ca0106_interrupt()
1331 snd_ca0106_ptr_write(chip, EXTENDED_INT, 0, stat76); in snd_ca0106_interrupt()
1333 if (chip->midi.dev_id && in snd_ca0106_interrupt()
1334 (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { in snd_ca0106_interrupt()
1335 if (chip->midi.interrupt) in snd_ca0106_interrupt()
1336 chip->midi.interrupt(&chip->midi, status); in snd_ca0106_interrupt()
1338 chip->midi.interrupt_disable(&chip->midi, chip->midi.tx_enable | chip->midi.rx_enable); in snd_ca0106_interrupt()
1342 outl(status, chip->port+IPR); in snd_ca0106_interrupt()
1469 static void ca0106_init_chip(struct snd_ca0106 *chip, int resume) in ca0106_init_chip() argument
1474 outl(0, chip->port + INTE); in ca0106_init_chip()
1496 chip->spdif_str_bits[0] = chip->spdif_bits[0] = def_bits; in ca0106_init_chip()
1497 chip->spdif_str_bits[1] = chip->spdif_bits[1] = def_bits; in ca0106_init_chip()
1498 chip->spdif_str_bits[2] = chip->spdif_bits[2] = def_bits; in ca0106_init_chip()
1499 chip->spdif_str_bits[3] = chip->spdif_bits[3] = def_bits; in ca0106_init_chip()
1502 snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]); in ca0106_init_chip()
1503 snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]); in ca0106_init_chip()
1504 snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]); in ca0106_init_chip()
1505 snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]); in ca0106_init_chip()
1507 snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000); in ca0106_init_chip()
1508 snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000); in ca0106_init_chip()
1511 outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); in ca0106_init_chip()
1512 outw(0x8000, chip->port + AC97DATA); in ca0106_init_chip()
1514 snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006); in ca0106_init_chip()
1515 snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006); in ca0106_init_chip()
1516 snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006); in ca0106_init_chip()
1517 snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006); in ca0106_init_chip()
1524 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); in ca0106_init_chip()
1528 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); in ca0106_init_chip()
1530 chip->spdif_enable = 0; /* Set digital SPDIF output off */ in ca0106_init_chip()
1535 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000); in ca0106_init_chip()
1539 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff); in ca0106_init_chip()
1541 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000); in ca0106_init_chip()
1543 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000); in ca0106_init_chip()
1545 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410); in ca0106_init_chip()
1546 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676); in ca0106_init_chip()
1547 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410); in ca0106_init_chip()
1548 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676); in ca0106_init_chip()
1552 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030); in ca0106_init_chip()
1553 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030); in ca0106_init_chip()
1555 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); in ca0106_init_chip()
1556 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); in ca0106_init_chip()
1557 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); in ca0106_init_chip()
1558 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); in ca0106_init_chip()
1561 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1563 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); in ca0106_init_chip()
1566 chip->capture_source = 3; in ca0106_init_chip()
1567 } else if (chip->details->ac97 == 1) { in ca0106_init_chip()
1569 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4); in ca0106_init_chip()
1572 chip->capture_source = 4; in ca0106_init_chip()
1575 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); in ca0106_init_chip()
1578 chip->capture_source = 3; in ca0106_init_chip()
1581 if (chip->details->gpio_type == 2) { in ca0106_init_chip()
1586 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1588 outl(0x005f5301, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1589 } else if (chip->details->gpio_type == 1) { in ca0106_init_chip()
1594 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1596 outl(0x005f5301, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1598 outl(0x0, chip->port+GPIO); in ca0106_init_chip()
1599 outl(0x005f03a3, chip->port+GPIO); /* Analog */ in ca0106_init_chip()
1602 snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */ in ca0106_init_chip()
1609 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); in ca0106_init_chip()
1611 if (chip->details->i2c_adc == 1) { in ca0106_init_chip()
1618 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], in ca0106_init_chip()
1621 chip->i2c_capture_volume[n][0] = 0xcf; in ca0106_init_chip()
1622 chip->i2c_capture_volume[n][1] = 0xcf; in ca0106_init_chip()
1624 chip->i2c_capture_source = 2; /* Line in */ in ca0106_init_chip()
1629 if (chip->details->spi_dac) { in ca0106_init_chip()
1637 snd_ca0106_spi_write(chip, spi_dac_init[n]); in ca0106_init_chip()
1638 if (reg < ARRAY_SIZE(chip->spi_dac_reg)) in ca0106_init_chip()
1639 chip->spi_dac_reg[reg] = spi_dac_init[n]; in ca0106_init_chip()
1643 snd_ca0106_pcm_power_dac(chip, PCM_FRONT_CHANNEL, 1); in ca0106_init_chip()
1647 static void ca0106_stop_chip(struct snd_ca0106 *chip) in ca0106_stop_chip() argument
1650 snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0); in ca0106_stop_chip()
1651 outl(0, chip->port + INTE); in ca0106_stop_chip()
1652 snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0); in ca0106_stop_chip()
1656 outl(0, chip->port + HCFG); in ca0106_stop_chip()
1667 struct snd_ca0106 *chip; in snd_ca0106_create() local
1686 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_ca0106_create()
1687 if (chip == NULL) { in snd_ca0106_create()
1692 chip->card = card; in snd_ca0106_create()
1693 chip->pci = pci; in snd_ca0106_create()
1694 chip->irq = -1; in snd_ca0106_create()
1696 spin_lock_init(&chip->emu_lock); in snd_ca0106_create()
1698 chip->port = pci_resource_start(pci, 0); in snd_ca0106_create()
1699 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106"); in snd_ca0106_create()
1700 if (!chip->res_port) { in snd_ca0106_create()
1701 snd_ca0106_free(chip); in snd_ca0106_create()
1707 IRQF_SHARED, KBUILD_MODNAME, chip)) { in snd_ca0106_create()
1708 snd_ca0106_free(chip); in snd_ca0106_create()
1712 chip->irq = pci->irq; in snd_ca0106_create()
1716 1024, &chip->buffer) < 0) { in snd_ca0106_create()
1717 snd_ca0106_free(chip); in snd_ca0106_create()
1723 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); in snd_ca0106_create()
1724 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); in snd_ca0106_create()
1726 chip->model, pci->revision, chip->serial); in snd_ca0106_create()
1734 } else if (c->serial == chip->serial) in snd_ca0106_create()
1737 chip->details = c; in snd_ca0106_create()
1741 c->name, chip->serial, subsystem[dev]); in snd_ca0106_create()
1745 c->name, chip->port, chip->irq); in snd_ca0106_create()
1747 ca0106_init_chip(chip, 0); in snd_ca0106_create()
1749 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_ca0106_create()
1751 snd_ca0106_free(chip); in snd_ca0106_create()
1754 *rchip = chip; in snd_ca0106_create()
1790 static int snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel) in snd_ca0106_midi() argument
1798 midi = &chip->midi2; in snd_ca0106_midi()
1806 midi = &chip->midi; in snd_ca0106_midi()
1832 midi->dev_id = chip; in snd_ca0106_midi()
1834 if ((err = ca_midi_init(chip, midi, 0, name)) < 0) in snd_ca0106_midi()
1846 struct snd_ca0106 *chip; in snd_ca0106_probe() local
1861 err = snd_ca0106_create(dev, card, pci, &chip); in snd_ca0106_probe()
1864 card->private_data = chip; in snd_ca0106_probe()
1867 err = snd_ca0106_pcm(chip, i); in snd_ca0106_probe()
1872 if (chip->details->ac97 == 1) { in snd_ca0106_probe()
1874 err = snd_ca0106_ac97(chip); in snd_ca0106_probe()
1878 err = snd_ca0106_mixer(chip); in snd_ca0106_probe()
1883 err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A); in snd_ca0106_probe()
1889 snd_ca0106_proc_init(chip); in snd_ca0106_probe()
1914 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_suspend() local
1919 snd_pcm_suspend_all(chip->pcm[i]); in snd_ca0106_suspend()
1920 if (chip->details->ac97) in snd_ca0106_suspend()
1921 snd_ac97_suspend(chip->ac97); in snd_ca0106_suspend()
1922 snd_ca0106_mixer_suspend(chip); in snd_ca0106_suspend()
1924 ca0106_stop_chip(chip); in snd_ca0106_suspend()
1931 struct snd_ca0106 *chip = card->private_data; in snd_ca0106_resume() local
1934 ca0106_init_chip(chip, 1); in snd_ca0106_resume()
1936 if (chip->details->ac97) in snd_ca0106_resume()
1937 snd_ac97_resume(chip->ac97); in snd_ca0106_resume()
1938 snd_ca0106_mixer_resume(chip); in snd_ca0106_resume()
1939 if (chip->details->spi_dac) { in snd_ca0106_resume()
1940 for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++) in snd_ca0106_resume()
1941 snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]); in snd_ca0106_resume()