Lines Matching +full:attenuation +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * James Courtier-Dutton <James@superbug.co.uk>
85 if (emu->audigy) {
128 { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */
129 { 0x0f, 0xcf }, /* Attenuation Right 0.5dB steps */
146 HCFG_MUTEBUTTONENABLE, emu->port + HCFG);
148 outl(0, emu->port + INTE);
169 if (emu->audigy) {
182 SPCS0, emu->spdif_bits[0],
183 SPCS1, emu->spdif_bits[1],
184 SPCS2, emu->spdif_bits[2],
187 if (emu->card_capabilities->emu_model) {
188 } else if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
199 /* Enabled Phased (8-channel) P16V playback */
200 outl(0x0201, emu->port + HCFG2);
203 } else if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
205 dev_info(emu->card->dev, "Audigy2 value: Special config.\n");
221 tmp = inw(emu->port + A_IOCFG) & ~0x8; /* Clear bit 3 */
222 outw(tmp, emu->port + A_IOCFG);
224 if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */
232 /* Enable GPIOs
234 * GPIO1: Speakers-enabled.
242 outw(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */
244 if (emu->card_capabilities->i2c_adc) { /* Audigy 2 ZS Notebook with ADC Wolfson WM8775 */
248 tmp = inw(emu->port + A_IOCFG);
249 outw(tmp | 0x4, emu->port + A_IOCFG); /* Set bit 2 for mic input */
250 tmp = inw(emu->port + A_IOCFG);
255 emu->i2c_capture_volume[n][0] = 0xcf;
256 emu->i2c_capture_volume[n][1] = 0xcf;
261 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr);
265 silent_page = (emu->silent_page.addr << emu->address_mode) | (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
271 if (emu->card_capabilities->emu_model) {
274 HCFG_AUDIOENABLE, emu->port + HCFG);
282 } else if (emu->audigy) {
283 if (emu->revision == 4) /* audigy2 */
287 HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
289 outl(HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
290 /* FIXME: Remove all these emu->model and replace it with a card recognition parameter,
291 * e.g. card_capabilities->joystick */
292 } else if (emu->model == 0x20 ||
293 emu->model == 0xc400 ||
294 (emu->model == 0x21 && emu->revision < 6))
295 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG);
297 /* With on-chip joystick */
298 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
301 if (emu->card_capabilities->emu_model) {
303 } else if (emu->card_capabilities->i2c_adc) {
305 } else if (emu->audigy) {
306 u16 reg = inw(emu->port + A_IOCFG);
307 outw(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
309 outw(reg | A_IOCFG_GPOUT1 | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
311 outw(reg, emu->port + A_IOCFG);
313 unsigned int reg = inl(emu->port + HCFG);
314 outl(reg | HCFG_GPOUT2, emu->port + HCFG);
316 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG);
318 outl(reg, emu->port + HCFG);
322 if (emu->card_capabilities->emu_model) {
324 } else if (emu->card_capabilities->i2c_adc) {
326 } else if (emu->audigy) { /* enable analog output */
327 u16 reg = inw(emu->port + A_IOCFG);
328 outw(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG);
331 if (emu->address_mode == 0) {
333 outl(inl(emu->port + HCFG) | HCFG_EXPANDED_MEM, emu->port + HCFG);
344 outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG);
347 if (emu->card_capabilities->emu_model) {
349 } else if (emu->card_capabilities->i2c_adc) {
351 } else if (emu->audigy) {
352 outw(inw(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
354 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
358 outw(inw(emu->port + A_IOCFG) | 0x0040, emu->port + A_IOCFG);
359 } else if (emu->card_capabilities->ca0108_chip) { /* audigy2 value */
361 outw(inw(emu->port + A_IOCFG) | 0x0060, emu->port + A_IOCFG);
364 outw(inw(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG);
371 /* FIXME: the following routine disables LiveDrive-II !! */
373 emu->tos_link = 0;
374 tmp = inl(emu->port + HCFG);
376 outl(tmp|0x800, emu->port + HCFG);
378 if (tmp != (inl(emu->port + HCFG) & ~0x800)) {
379 emu->tos_link = 1;
380 outl(tmp, emu->port + HCFG);
386 if (emu->card_capabilities->emu_model)
396 outl(0, emu->port + INTE);
412 if (emu->audigy)
440 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG);
481 #define EC_CURRENT_PROM_VERSION 0x01 /* Self-explanatory. This should
485 #define EC_EEPROM_SIZE 0x40 /* ECARD EEPROM has 64 16-bit words */
496 * and is stored as a NULL-terminated
502 /* Most of this stuff is pretty self-evident. According to the hardware
516 * control latch will is loaded bit-serially by toggling the Modem control
529 hc_port = emu->port + HCFG;
555 * right channel. The following table maps from the Gain/Attenuation
566 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN);
569 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN);
574 value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA);
585 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
593 emu->ecard_ctrl = EC_RAW_RUN_MODE |
599 hc_value = inl(emu->port + HCFG);
600 outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG);
601 inl(emu->port + HCFG);
620 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
634 * before the rest of the IO-Ports become active.
636 special_port = emu->port + 0x38;
655 /* firmware file names, per model, init-fw and dock-fw (optional) */
678 filename = firmware_names[emu->card_capabilities->emu_model][dock];
681 err = request_firmware(fw, filename, &emu->pci->dev);
695 // The docking events clearly arrive prematurely - while the
701 dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n");
702 err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw);
708 dev_dbg(emu->card->dev, "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp);
711 dev_err(emu->card->dev,
716 dev_info(emu->card->dev, "emu1010: Audio Dock Firmware loaded\n");
720 dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2);
738 dev_info(emu->card->dev, "emu1010: Audio Dock detached\n");
739 /* The hardware auto-mutes all, so we unmute again */
748 scoped_guard(spinlock_irq, &emu->reg_lock) {
750 emu->emu1010.clock_source = emu->emu1010.clock_fallback;
751 emu->emu1010.wclock = 1 - emu->emu1010.clock_source;
754 snd_ctl_build_ioff(&id, emu->ctl_clock_source, 0);
755 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE, &id);
764 if (emu->card->shutdown)
767 if (emu->suspend)
788 u16 sts = inw(emu->port + A_GPIO);
789 u16 bit = emu->card_capabilities->ca0108_chip ? 0x2000 : 0x8000;
793 schedule_work(&emu->emu1010.work);
798 * ----------------------------
801 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops
802 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops
809 dev_info(emu->card->dev, "emu1010: Special config.\n");
813 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG);
817 dev_info(emu->card->dev, "emu1010: Loading Hana Firmware\n");
818 err = snd_emu1010_load_firmware(emu, 0, &emu->firmware);
820 dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n");
828 dev_info(emu->card->dev,
831 return -ENODEV;
834 dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n");
837 dev_info(emu->card->dev, "emu1010: Hana version: %u.%u\n", tmp, tmp2);
842 dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
845 if (emu->card_capabilities->no_adat) {
846 emu->emu1010.optical_in = 0; /* IN_SPDIF */
847 emu->emu1010.optical_out = 0; /* OUT_SPDIF */
849 /* Optical -> ADAT I/O */
850 emu->emu1010.optical_in = 1; /* IN_ADAT */
851 emu->emu1010.optical_out = 1; /* OUT_ADAT */
853 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : EMU_HANA_OPTICAL_IN_SPDIF) |
854 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : EMU_HANA_OPTICAL_OUT_SPDIF);
856 /* Set no attenuation on Audio Dock pads. */
857 emu->emu1010.adc_pads = 0x00;
858 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, emu->emu1010.adc_pads);
859 /* Unmute Audio dock DACs, Headphone source DAC-4. */
862 emu->emu1010.dac_pads = EMU_HANA_DOCK_DAC_PAD1 | EMU_HANA_DOCK_DAC_PAD2 |
864 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, emu->emu1010.dac_pads);
871 emu->gpio_interrupt = emu1010_interrupt;
877 emu->emu1010.clock_source = 1; /* 48000 */
878 emu->emu1010.clock_fallback = 1; /* 48000 */
882 emu->emu1010.wclock = EMU_HANA_WCLOCK_INT_48K;
904 struct snd_emu10k1 *emu = card->private_data;
906 if (emu->port) { /* avoid access to already used hardware */
911 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
915 cancel_work_sync(&emu->emu1010.work);
916 mutex_destroy(&emu->emu1010.lock);
917 release_firmware(emu->firmware);
918 release_firmware(emu->dock_fw);
919 snd_util_memhdr_free(emu->memhdr);
920 if (emu->silent_page.area)
921 snd_dma_free_pages(&emu->silent_page);
922 if (emu->ptb_pages.area)
923 snd_dma_free_pages(&emu->ptb_pages);
924 vfree(emu->page_ptr_table);
925 vfree(emu->page_addr_table);
934 /* DSP: CA10300-IAT LF
935 * DAC: Cirrus Logic CS4382-KQZ
955 * 3: 0 - Digital Out, 1 - Line in
971 * 0 - Digital Out
972 * 1 - Line in
980 /* DSP: CA10300-IAT LF
981 * DAC: Cirrus Logic CS4382-KQZ
998 /* DSP: CA0108-IAT
999 * DAC: CS4382-KQ
1046 * 8-9: 0 = Line in/Mic, 2 = Optical in, 3 = Nothing.
1047 * A-B: 0 = Headphones, 2 = Optical out, 3 = Nothing.
1048 * C-D: 2 = Front/Rear/etc, 3 = nothing.
1049 * E-F: Always 0
1062 /* Attach MicroDock[M] to make it an E-MU 1616[m]. */
1066 .driver = "Audigy2", .name = "E-MU 02 CardBus [MAEM8950]",
1075 /* Attach 0202 daughter card to make it an E-MU 1212m, OR a
1076 * MicroDock[M] to make it an E-MU 1616[m]. */
1079 .driver = "Audigy2", .name = "E-MU 1010b PCI [MAEM8960]",
1087 /* Attach 0202 daughter card to make it an E-MU 1212m, OR a
1088 * MicroDockM to make it an E-MU 1616m. The non-m
1093 .driver = "Audigy2", .name = "E-MU 1010 PCIe [MAEM8986]",
1101 /* Attach 0202 daughter card to make it an E-MU 1212m, OR an
1102 * AudioDock[M] to make it an E-MU 1820[m]. */
1105 .driver = "Audigy2", .name = "E-MU 1010 [MAEM8810]",
1115 .driver = "Audigy2", .name = "E-MU 0404b PCI [MAEM8852]",
1124 /* Tested by James@superbug.co.uk 20-3-2007. */
1126 .driver = "Audigy2", .name = "E-MU 0404 [MAEM8850]",
1136 .driver = "Audigy2", .name = "E-MU 0404 PCIe [MAEM8984]",
1159 /* Tested by shane-alsa@cm.nu 5th Nov 2005 */
1207 /* DSP: CA0102-IAT
1208 * DAC: CS4382-KQ
1404 .driver = "EMU10K1", .name = "E-MU APS [PC545]",
1441 * detect that the device is behind a non-passthrough IOMMU.
1447 emu->iommu_workaround = false;
1449 domain = iommu_get_domain_for_dev(emu->card->dev);
1450 if (!domain || domain->type == IOMMU_DOMAIN_IDENTITY)
1453 dev_notice(emu->card->dev,
1454 "non-passthrough IOMMU detected, widening DMA allocations");
1455 emu->iommu_workaround = true;
1466 struct snd_emu10k1 *emu = card->private_data;
1479 card->private_free = snd_emu10k1_free;
1480 emu->card = card;
1481 spin_lock_init(&emu->reg_lock);
1482 spin_lock_init(&emu->emu_lock);
1483 spin_lock_init(&emu->spi_lock);
1484 spin_lock_init(&emu->i2c_lock);
1485 spin_lock_init(&emu->voice_lock);
1486 spin_lock_init(&emu->synth_lock);
1487 spin_lock_init(&emu->memblk_lock);
1488 mutex_init(&emu->fx8010.lock);
1489 INIT_LIST_HEAD(&emu->mapped_link_head);
1490 INIT_LIST_HEAD(&emu->mapped_order_link_head);
1491 emu->pci = pci;
1492 emu->irq = -1;
1493 emu->synth = NULL;
1494 emu->get_synth_voice = NULL;
1495 INIT_WORK(&emu->emu1010.work, emu1010_work);
1496 mutex_init(&emu->emu1010.lock);
1498 emu->revision = pci->revision;
1499 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1500 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1501 dev_dbg(card->dev,
1503 pci->vendor, pci->device, emu->serial, emu->model);
1505 for (c = emu_chip_details; c->vendor; c++) {
1506 if (c->vendor == pci->vendor && c->device == pci->device) {
1508 if (c->subsystem && (c->subsystem == subsystem))
1513 if (c->subsystem && (c->subsystem != emu->serial))
1515 if (c->revision && c->revision != emu->revision)
1521 if (c->vendor == 0) {
1522 dev_err(card->dev, "emu10k1: Card not recognised\n");
1523 return -ENOENT;
1525 emu->card_capabilities = c;
1526 if (c->subsystem && !subsystem)
1527 dev_dbg(card->dev, "Sound card name = %s\n", c->name);
1529 dev_dbg(card->dev, "Sound card name = %s, "
1531 "Forced to subsystem = 0x%x\n", c->name,
1532 pci->vendor, pci->device, emu->serial, c->subsystem);
1534 dev_dbg(card->dev, "Sound card name = %s, "
1536 c->name, pci->vendor, pci->device,
1537 emu->serial);
1539 if (!*card->id && c->id)
1540 strscpy(card->id, c->id, sizeof(card->id));
1542 is_audigy = emu->audigy = c->emu10k2_chip;
1547 emu->address_mode = is_audigy ? 0 : 1;
1549 emu->dma_mask = emu->address_mode ? EMU10K1_DMA_MASK : AUDIGY_DMA_MASK;
1550 if (dma_set_mask_and_coherent(&pci->dev, emu->dma_mask) < 0) {
1551 dev_err(card->dev,
1553 emu->dma_mask);
1554 return -ENXIO;
1557 emu->gpr_base = A_FXGPREGBASE;
1559 emu->gpr_base = FXGPREGBASE;
1564 emu->port = pci_resource_start(pci, 0);
1566 emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT;
1568 page_table_size = sizeof(u32) * (emu->address_mode ? MAXPAGES1 :
1571 &emu->ptb_pages) < 0)
1572 return -ENOMEM;
1573 dev_dbg(card->dev, "page table address range is %.8lx:%.8lx\n",
1574 (unsigned long)emu->ptb_pages.addr,
1575 (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
1577 emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
1578 emu->max_cache_pages));
1579 emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
1580 emu->max_cache_pages));
1581 if (!emu->page_ptr_table || !emu->page_addr_table)
1582 return -ENOMEM;
1585 &emu->silent_page) < 0)
1586 return -ENOMEM;
1587 dev_dbg(card->dev, "silent page range is %.8lx:%.8lx\n",
1588 (unsigned long)emu->silent_page.addr,
1589 (unsigned long)(emu->silent_page.addr +
1590 emu->silent_page.bytes));
1592 emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE);
1593 if (!emu->memhdr)
1594 return -ENOMEM;
1595 emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) -
1606 emu->fx8010.extin_mask = extin_mask;
1607 emu->fx8010.extout_mask = extout_mask;
1608 emu->enable_ir = enable_ir;
1610 if (emu->card_capabilities->ca_cardbus_chip) {
1615 if (emu->card_capabilities->ecard) {
1619 } else if (emu->card_capabilities->emu_model) {
1631 emu->fx8010.itram_size = (16 * 1024)/2;
1632 emu->fx8010.etram_pages.area = NULL;
1633 emu->fx8010.etram_pages.bytes = 0;
1636 if (devm_request_irq(&pci->dev, pci->irq, snd_emu10k1_interrupt,
1638 return -EBUSY;
1639 emu->irq = pci->irq;
1640 card->sync_irq = emu->irq;
1656 emu->spdif_bits[0] = emu->spdif_bits[1] =
1657 emu->spdif_bits[2] = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
1663 memset(emu->silent_page.area, 0, emu->silent_page.bytes);
1664 silent_page = emu->silent_page.addr << emu->address_mode;
1665 pgtbl = (__le32 *)emu->ptb_pages.area;
1666 for (idx = 0; idx < (emu->address_mode ? MAXPAGES1 : MAXPAGES0); idx++)
1671 emu->voices[idx].number = idx;
1715 if (emu->audigy)
1717 emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size));
1718 if (!emu->saved_ptr)
1719 return -ENOMEM;
1721 return -ENOMEM;
1722 if (emu->card_capabilities->ca0151_chip &&
1724 return -ENOMEM;
1730 vfree(emu->saved_ptr);
1732 if (emu->card_capabilities->ca0151_chip)
1742 val = emu->saved_ptr;
1746 if (emu->audigy) {
1751 if (emu->audigy)
1752 emu->saved_a_iocfg = inw(emu->port + A_IOCFG);
1753 emu->saved_hcfg = inl(emu->port + HCFG);
1758 if (emu->card_capabilities->ca_cardbus_chip)
1760 if (emu->card_capabilities->ecard)
1762 else if (emu->card_capabilities->emu_model)
1766 snd_emu10k1_init(emu, emu->enable_ir);
1778 if (emu->audigy)
1779 outw(emu->saved_a_iocfg, emu->port + A_IOCFG);
1780 outl(emu->saved_hcfg, emu->port + HCFG);
1782 val = emu->saved_ptr;
1786 if (emu->audigy) {