--- zzzz-none-000/linux-3.10.107/sound/pci/intel8x0.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/intel8x0.c 2021-02-04 17:41:59.000000000 +0000 @@ -26,7 +26,7 @@ * */ -#include +#include #include #include #include @@ -430,7 +430,7 @@ u32 int_sta_mask; /* interrupt status mask */ }; -static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0_ids) = { +static const struct pci_device_id snd_intel8x0_ids[] = { { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */ { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */ { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */ @@ -547,7 +547,8 @@ /* access to some forbidden (non existent) ac97 registers will not * reset the semaphore. So even if you don't get the semaphore, still * continue the access. We don't need the semaphore anyway. */ - snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n", + dev_err(chip->card->dev, + "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n", igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA))); iagetword(chip, 0); /* clear semaphore flag */ /* I don't care about the semaphore */ @@ -562,7 +563,9 @@ if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { if (! chip->in_ac97_init) - snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); + dev_err(chip->card->dev, + "codec_write %d: semaphore is not ready for register 0x%x\n", + ac97->num, reg); } iaputword(chip, reg + ac97->num * 0x80, val); } @@ -576,7 +579,9 @@ if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { if (! chip->in_ac97_init) - snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); + dev_err(chip->card->dev, + "codec_read %d: semaphore is not ready for register 0x%x\n", + ac97->num, reg); res = 0xffff; } else { res = iagetword(chip, reg + ac97->num * 0x80); @@ -585,7 +590,9 @@ iputdword(chip, ICHREG(GLOB_STA), tmp & ~(chip->codec_ready_bits | ICH_GSCI)); if (! chip->in_ac97_init) - snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg); + dev_err(chip->card->dev, + "codec_read %d: read timeout for register 0x%x\n", + ac97->num, reg); res = 0xffff; } } @@ -619,7 +626,7 @@ return 0; } if (! chip->in_ac97_init) - snd_printd(KERN_WARNING "intel8x0: AC97 codec ready timeout.\n"); + dev_warn(chip->card->dev, "AC97 codec ready timeout.\n"); return -EBUSY; } @@ -631,7 +638,7 @@ while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) udelay(1); if (! time && ! chip->in_ac97_init) - snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n"); + dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n"); return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY); } @@ -700,7 +707,7 @@ bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ ichdev->fragsize >> ichdev->pos_shift); #if 0 - printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n", + dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]); #endif } @@ -712,8 +719,8 @@ ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; ichdev->position = 0; #if 0 - printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, " - "period_size1 = 0x%x\n", + dev_dbg(chip->card->dev, + "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n", ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1); #endif @@ -781,8 +788,8 @@ ichdev->lvi_frag %= ichdev->frags; ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1); #if 0 - printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, " - "all = 0x%x, 0x%x\n", + dev_dbg(chip->card->dev, + "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), inl(port + 4), inb(port + ICH_REG_OFF_CR)); @@ -1541,17 +1548,16 @@ snd_dma_pci_data(chip->pci), rec->prealloc_size, rec->prealloc_max_size); - if (rec->ac97_idx == ICHD_PCMOUT && rec->playback_ops) { + if (rec->playback_ops && + rec->playback_ops->open == snd_intel8x0_playback_open) { struct snd_pcm_chmap *chmap; int chs = 2; - if (rec->ac97_idx == ICHD_PCMOUT) { - if (chip->multi8) - chs = 8; - else if (chip->multi6) - chs = 6; - else if (chip->multi4) - chs = 4; - } + if (chip->multi8) + chs = 8; + else if (chip->multi6) + chs = 6; + else if (chip->multi4) + chs = 4; err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, chs, 0, &chmap); @@ -1789,7 +1795,7 @@ }, }; -static struct ac97_quirk ac97_quirks[] = { +static const struct ac97_quirk ac97_quirks[] = { { .subvendor = 0x0e11, .subdevice = 0x000e, @@ -2290,7 +2296,8 @@ ac97.num = i; if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { if (err != -EACCES) - snd_printk(KERN_ERR "Unable to initialize codec #%d\n", i); + dev_err(chip->card->dev, + "Unable to initialize codec #%d\n", i); if (i == 0) goto __err; } @@ -2442,7 +2449,7 @@ return 0; schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); - snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", + dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT))); return -EIO; } @@ -2484,7 +2491,8 @@ } while (time_after_eq(end_time, jiffies)); if (! status) { /* no codec is found */ - snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", + dev_err(chip->card->dev, + "codec_ready: codec is not ready [0x%x]\n", igetdword(chip, ICHREG(GLOB_STA))); return -EIO; } @@ -2548,7 +2556,7 @@ goto __ok; schedule_timeout_uninterruptible(1); } - snd_printk(KERN_ERR "AC'97 reset failed.\n"); + dev_err(chip->card->dev, "AC'97 reset failed.\n"); if (probing) return -EIO; @@ -2592,7 +2600,7 @@ break; } if (timeout == 0) - printk(KERN_ERR "intel8x0: reset of registers failed?\n"); + dev_err(chip->card->dev, "reset of registers failed?\n"); } /* initialize Buffer Descriptor Lists */ for (i = 0; i < chip->bdbars_count; i++) @@ -2646,7 +2654,6 @@ */ static int intel8x0_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct intel8x0 *chip = card->private_data; int i; @@ -2674,12 +2681,6 @@ free_irq(chip->irq, chip); chip->irq = -1; } - pci_disable_device(pci); - pci_save_state(pci); - /* The call below may disable built-in speaker on some laptops - * after S2RAM. So, don't touch it. - */ - /* pci_set_power_state(pci, PCI_D3hot); */ return 0; } @@ -2690,20 +2691,11 @@ struct intel8x0 *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - printk(KERN_ERR "intel8x0: pci_enable_device failed, " - "disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); snd_intel8x0_chip_init(chip, 0); if (request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { - printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " - "disabling device\n", pci->irq); + dev_err(dev, "unable to grab IRQ %d, disabling device\n", + pci->irq); snd_card_disconnect(card); return -EIO; } @@ -2772,7 +2764,7 @@ unsigned long port; unsigned long pos, pos1, t; int civ, timeout = 1000, attempt = 1; - struct timespec start_time, stop_time; + ktime_t start_time, stop_time; if (chip->ac97_bus->clock != 48000) return; /* specified in module option */ @@ -2780,7 +2772,8 @@ __again: subs = chip->pcm[0]->streams[0].substream; if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { - snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); + dev_warn(chip->card->dev, + "no playback buffer allocated - aborting measure ac97 clock\n"); return; } ichdev = &chip->ichd[ICHD_PCMOUT]; @@ -2790,7 +2783,8 @@ /* set rate */ if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) { - snd_printk(KERN_ERR "cannot set ac97 rate: clock = %d\n", chip->ac97_bus->clock); + dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n", + chip->ac97_bus->clock); return; } snd_intel8x0_setup_periods(chip, ichdev); @@ -2804,7 +2798,7 @@ iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); } - do_posix_clock_monotonic_gettime(&start_time); + start_time = ktime_get(); spin_unlock_irq(&chip->reg_lock); msleep(50); spin_lock_irq(&chip->reg_lock); @@ -2828,7 +2822,7 @@ pos += ichdev->position; } chip->in_measurement = 0; - do_posix_clock_monotonic_gettime(&stop_time); + stop_time = ktime_get(); /* stop */ if (chip->device_type == DEVICE_ALI) { iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); @@ -2844,7 +2838,8 @@ spin_unlock_irq(&chip->reg_lock); if (pos == 0) { - snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n"); + dev_err(chip->card->dev, + "measure - unreliable DMA position..\n"); __retry: if (attempt < 3) { msleep(300); @@ -2855,19 +2850,18 @@ } pos /= 4; - t = stop_time.tv_sec - start_time.tv_sec; - t *= 1000000; - t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000; - printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); + t = ktime_us_delta(stop_time, start_time); + dev_info(chip->card->dev, + "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); if (t == 0) { - snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n"); + dev_err(chip->card->dev, "?? calculation error..\n"); goto __retry; } pos *= 1000; pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; if (pos < 40000 || pos >= 60000) { /* abnormal value. hw problem? */ - printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); + dev_info(chip->card->dev, "measured clock %ld rejected\n", pos); goto __retry; } else if (pos > 40500 && pos < 41500) /* first exception - 41000Hz reference clock */ @@ -2879,7 +2873,7 @@ /* not 48000Hz, tuning the clock.. */ chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; __end: - printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock); + dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock); snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); } @@ -2901,13 +2895,12 @@ wl = snd_pci_quirk_lookup(pci, intel8x0_clock_list); if (!wl) return 0; - printk(KERN_INFO "intel8x0: white list rate for %04x:%04x is %i\n", + dev_info(chip->card->dev, "white list rate for %04x:%04x is %i\n", pci->subsystem_vendor, pci->subsystem_device, wl->value); chip->ac97_bus->clock = wl->value; return 1; } -#ifdef CONFIG_PROC_FS static void snd_intel8x0_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { @@ -2949,9 +2942,6 @@ if (! snd_card_proc_new(chip->card, "intel8x0", &entry)) snd_info_set_text_ops(entry, chip, snd_intel8x0_proc_read); } -#else -#define snd_intel8x0_proc_init(x) -#endif static int snd_intel8x0_dev_free(struct snd_device *device) { @@ -3005,7 +2995,7 @@ fini: if (msg != NULL) - printk(KERN_INFO "intel8x0: %s optimization\n", msg); + dev_info(&pci->dev, "%s optimization\n", msg); return result; } @@ -3100,7 +3090,7 @@ else chip->addr = pci_iomap(pci, 0, 0); if (!chip->addr) { - snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); + dev_err(card->dev, "AC'97 space ioremap problem\n"); snd_intel8x0_free(chip); return -EIO; } @@ -3108,13 +3098,13 @@ chip->bmaddr = pci_iomap(pci, 3, 0); else chip->bmaddr = pci_iomap(pci, 1, 0); + + port_inited: if (!chip->bmaddr) { - snd_printk(KERN_ERR "Controller space ioremap problem\n"); + dev_err(card->dev, "Controller space ioremap problem\n"); snd_intel8x0_free(chip); return -EIO; } - - port_inited: chip->bdbars_count = bdbars[device_type]; /* initialize offsets */ @@ -3154,7 +3144,7 @@ chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, &chip->bdbars) < 0) { snd_intel8x0_free(chip); - snd_printk(KERN_ERR "intel8x0: cannot allocate buffer descriptors\n"); + dev_err(card->dev, "cannot allocate buffer descriptors\n"); return -ENOMEM; } /* tables must be aligned to 8 bytes here, but the kernel pages @@ -3208,7 +3198,7 @@ /* request irq after initializaing int_sta_mask, etc */ if (request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { - snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); snd_intel8x0_free(chip); return -EBUSY; } @@ -3219,8 +3209,6 @@ return err; } - snd_card_set_dev(card, &pci->dev); - *r_intel8x0 = chip; return 0; } @@ -3267,12 +3255,12 @@ w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults); if (w) { if (w->value) - snd_printdd(KERN_INFO - "intel8x0: Using SPDIF over AC-Link for %s\n", + dev_dbg(&pci->dev, + "Using SPDIF over AC-Link for %s\n", snd_pci_quirk_name(w)); else - snd_printdd(KERN_INFO - "intel8x0: Using integrated SPDIF DMA for %s\n", + dev_dbg(&pci->dev, + "Using integrated SPDIF DMA for %s\n", snd_pci_quirk_name(w)); return w->value; } @@ -3287,7 +3275,7 @@ int err; struct shortname_table *name; - err = snd_card_create(index, id, THIS_MODULE, 0, &card); + err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); if (err < 0) return err; @@ -3365,7 +3353,6 @@ static void snd_intel8x0_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); - pci_set_drvdata(pci, NULL); } static struct pci_driver intel8x0_driver = {