--- zzzz-none-000/linux-3.10.107/sound/pci/emu10k1/emu10k1_main.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/emu10k1/emu10k1_main.c 2021-02-04 17:41:59.000000000 +0000 @@ -217,7 +217,7 @@ } if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ /* Hacks for Alice3 to work independent of haP16V driver */ - snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); + dev_info(emu->card->dev, "Audigy2 value: Special config.\n"); /* Setup SRCMulti_I2S SamplingRate */ tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); tmp &= 0xfffff1ff; @@ -712,6 +712,7 @@ { struct snd_emu10k1 *emu = data; u32 tmp, tmp2, reg; + u32 last_reg = 0; int err; for (;;) { @@ -728,7 +729,8 @@ if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { /* Audio Dock attached */ /* Return to Audio Dock programming mode */ - snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); + dev_info(emu->card->dev, + "emu1010: Loading Audio Dock Firmware\n"); snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK); if (!emu->dock_fw) { @@ -761,28 +763,42 @@ snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ®); - snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg); + dev_info(emu->card->dev, + "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", + reg); /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg); + dev_info(emu->card->dev, + "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg); if ((reg & 0x1f) != 0x15) { /* FPGA failed to be programmed */ - snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg); + dev_info(emu->card->dev, + "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", + reg); continue; } - snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); + dev_info(emu->card->dev, + "emu1010: Audio Dock Firmware loaded\n"); snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); - snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n", + dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); /* Sync clocking between 1010 and Dock */ /* Allow DLL to settle */ msleep(10); /* Unmute all. Default is muted after a firmware load */ snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); + } else if (!reg && last_reg) { + /* Audio Dock removed */ + dev_info(emu->card->dev, + "emu1010: Audio Dock detached\n"); + /* Unmute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); } + + last_reg = reg; } - snd_printk(KERN_INFO "emu1010: firmware thread stopping\n"); + dev_info(emu->card->dev, "emu1010: firmware thread stopping\n"); return 0; } @@ -823,7 +839,7 @@ u32 tmp, tmp2, reg; int err; - snd_printk(KERN_INFO "emu1010: Special config.\n"); + dev_info(emu->card->dev, "emu1010: Special config.\n"); /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, * Lock Sound Memory Cache, Lock Tank Memory Cache, * Mute all codecs. @@ -848,7 +864,7 @@ /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - snd_printdd("reg1 = 0x%x\n", reg); + dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg); if ((reg & 0x3f) == 0x15) { /* FPGA netlist already present so clear it */ /* Return to programming mode */ @@ -856,13 +872,14 @@ snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02); } snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - snd_printdd("reg2 = 0x%x\n", reg); + dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg); if ((reg & 0x3f) == 0x15) { /* FPGA failed to return to programming mode */ - snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n"); + dev_info(emu->card->dev, + "emu1010: FPGA failed to return to programming mode\n"); return -ENODEV; } - snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg); + dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg); if (!emu->firmware) { const char *filename; @@ -885,16 +902,19 @@ err = request_firmware(&emu->firmware, filename, &emu->pci->dev); if (err != 0) { - snd_printk(KERN_ERR "emu1010: firmware: %s not found. Err = %d\n", filename, err); + dev_info(emu->card->dev, + "emu1010: firmware: %s not found. Err = %d\n", + filename, err); return err; } - snd_printk(KERN_INFO "emu1010: firmware file = %s, size = 0x%zx\n", + dev_info(emu->card->dev, + "emu1010: firmware file = %s, size = 0x%zx\n", filename, emu->firmware->size); } err = snd_emu1010_load_firmware(emu, emu->firmware); if (err != 0) { - snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n"); + dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); return err; } @@ -902,21 +922,23 @@ snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); if ((reg & 0x3f) != 0x15) { /* FPGA failed to be programmed */ - snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg); + dev_info(emu->card->dev, + "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", + reg); return -ENODEV; } - snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); + dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n"); snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp); snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2); - snd_printk(KERN_INFO "emu1010: Hana version: %u.%u\n", tmp, tmp2); + dev_info(emu->card->dev, "emu1010: Hana version: %u.%u\n", tmp, tmp2); /* Enable 48Volt power to Audio Dock */ snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON); snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); - snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg); + dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); - snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg); + dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp); /* Optical -> ADAT I/O */ /* 0 : SPDIF @@ -955,7 +977,7 @@ snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00); snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); - snd_printk(KERN_INFO "emu1010: Card options3 = 0x%x\n", reg); + dev_info(emu->card->dev, "emu1010: Card options3 = 0x%x\n", reg); /* Default WCLK set to 48kHz. */ snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00); /* Word Clock source, Internal 48kHz x1 */ @@ -1281,10 +1303,8 @@ } if (emu->emu1010.firmware_thread) kthread_stop(emu->emu1010.firmware_thread); - if (emu->firmware) - release_firmware(emu->firmware); - if (emu->dock_fw) - release_firmware(emu->dock_fw); + release_firmware(emu->firmware); + release_firmware(emu->dock_fw); if (emu->irq >= 0) free_irq(emu->irq, emu); /* remove reserved page */ @@ -1293,8 +1313,7 @@ (struct snd_util_memblk *)emu->reserved_page); emu->reserved_page = NULL; } - if (emu->memhdr) - snd_util_memhdr_free(emu->memhdr); + snd_util_memhdr_free(emu->memhdr); if (emu->silent_page.area) snd_dma_free_pages(&emu->silent_page); if (emu->ptb_pages.area) @@ -1320,6 +1339,22 @@ } static struct snd_emu_chip_details emu_chip_details[] = { + /* Audigy 5/Rx SB1550 */ + /* Tested by michael@gernoth.net 28 Mar 2015 */ + /* DSP: CA10300-IAT LF + * DAC: Cirrus Logic CS4382-KQZ + * ADC: Philips 1361T + * AC97: Sigmatel STAC9750 + * CA0151: None + */ + {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10241102, + .driver = "Audigy2", .name = "SB Audigy 5/Rx [SB1550]", + .id = "Audigy2", + .emu10k2_chip = 1, + .ca0108_chip = 1, + .spk71 = 1, + .adc_1361t = 1, /* 24 bit capture instead of 16bit */ + .ac97_chip = 1}, /* Audigy4 (Not PRO) SB0610 */ /* Tested by James@superbug.co.uk 4th April 2006 */ /* A_IOCFG bits @@ -1813,7 +1848,9 @@ emu->revision = pci->revision; pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); - snd_printdd("vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", pci->vendor, pci->device, emu->serial, emu->model); + dev_dbg(card->dev, + "vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", + pci->vendor, pci->device, emu->serial, emu->model); for (c = emu_chip_details; c->vendor; c++) { if (c->vendor == pci->vendor && c->device == pci->device) { @@ -1832,21 +1869,21 @@ } } if (c->vendor == 0) { - snd_printk(KERN_ERR "emu10k1: Card not recognised\n"); + dev_err(card->dev, "emu10k1: Card not recognised\n"); kfree(emu); pci_disable_device(pci); return -ENOENT; } emu->card_capabilities = c; if (c->subsystem && !subsystem) - snd_printdd("Sound card name = %s\n", c->name); + dev_dbg(card->dev, "Sound card name = %s\n", c->name); else if (subsystem) - snd_printdd("Sound card name = %s, " + dev_dbg(card->dev, "Sound card name = %s, " "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. " "Forced to subsystem = 0x%x\n", c->name, pci->vendor, pci->device, emu->serial, c->subsystem); else - snd_printdd("Sound card name = %s, " + dev_dbg(card->dev, "Sound card name = %s, " "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n", c->name, pci->vendor, pci->device, emu->serial); @@ -1874,9 +1911,11 @@ emu->address_mode = is_audigy ? 0 : 1; /* set the DMA transfer mask */ emu->dma_mask = emu->address_mode ? EMU10K1_DMA_MASK : AUDIGY_DMA_MASK; - if (pci_set_dma_mask(pci, emu->dma_mask) < 0 || - pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) { - snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask); + if (dma_set_mask(&pci->dev, emu->dma_mask) < 0 || + dma_set_coherent_mask(&pci->dev, emu->dma_mask) < 0) { + dev_err(card->dev, + "architecture does not support PCI busmaster DMA with mask 0x%lx\n", + emu->dma_mask); kfree(emu); pci_disable_device(pci); return -ENXIO; @@ -2024,11 +2063,10 @@ if (err < 0) goto error; -#ifdef CONFIG_PROC_FS +#ifdef CONFIG_SND_PROC_FS snd_emu10k1_proc_init(emu); #endif - snd_card_set_dev(card, &pci->dev); *remu = emu; return 0;