Ignore:
Timestamp:
May 16, 2020, 10:05:07 AM (5 years ago)
Author:
Paul Smedley
Message:

Commit 3..102 changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-linux-3.2.102/alsa-kernel/pci/intel8x0.c

    r598 r612  
    2525
    2626 *
    27  */
     27 */     
     28
     29#ifdef TARGET_OS2
     30#define KBUILD_MODNAME "intel8x0"
     31#endif
    2832
    2933#include <asm/io.h>
     
    3337#include <linux/pci.h>
    3438#include <linux/slab.h>
    35 #include <linux/moduleparam.h>
     39#include <linux/module.h>
    3640#include <sound/core.h>
    3741#include <sound/pcm.h>
     
    4246#include <asm/pgtable.h>
    4347#include <asm/cacheflush.h>
     48
     49#ifdef CONFIG_KVM_GUEST
     50#include <linux/kvm_para.h>
     51#else
     52#define kvm_para_available() (0)
     53#endif
    4454
    4555MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
     
    7888static int xbox;
    7989static int spdif_aclink = -1;
     90static int inside_vm = -1;
    8091
    8192module_param(index, int, 0444);
     
    95106module_param(spdif_aclink, int, 0444);
    96107MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
     108module_param(inside_vm, bool, 0444);
     109MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
    97110
    98111/* just for backward compatibility */
     
    269282
    270283/* interrupts for the whole chip by interrupt status register finish */
    271 
     284 
    272285#define ALI_INT_MICIN2          (1<<26)
    273286#define ALI_INT_PCMIN2          (1<<25)
     
    313326
    314327/*
    315  *
     328 * 
    316329 */
    317330
     
    401414        unsigned xbox: 1;               /* workaround for Xbox AC'97 detection */
    402415        unsigned buggy_semaphore: 1;    /* workaround for buggy codec semaphore */
     416        unsigned inside_vm: 1;          /* enable VM optimization */
    403417
    404418        int spdif_idx;  /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
     
    535549        } while (time--);
    536550
    537         /* access to some forbidden (non existant) ac97 registers will not
     551        /* access to some forbidden (non existent) ac97 registers will not
    538552         * reset the semaphore. So even if you don't get the semaphore, still
    539553         * continue the access. We don't need the semaphore anyway. */
     
    544558        return -EBUSY;
    545559}
    546 
     560 
    547561static void snd_intel8x0_codec_write(struct snd_ac97 *ac97,
    548562                                     unsigned short reg,
     
    662676 * DMA I/O
    663677 */
    664 static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev)
     678static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev) 
    665679{
    666680        int idx;
     
    886900                        /* clear FIFO for synchronization of channels */
    887901                        fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]);
    888                         fifo &= ~(0xff << (ichdev->ali_slot % 4));
    889                         fifo |= 0x83 << (ichdev->ali_slot % 4);
     902                        fifo &= ~(0xff << (ichdev->ali_slot % 4)); 
     903                        fifo |= 0x83 << (ichdev->ali_slot % 4); 
    890904                        iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo);
    891905                }
     
    10661080                        continue;
    10671081                }
    1068                 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
    1069                     ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
     1082                if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV))
     1083                        continue;
     1084
     1085                /* IO read operation is very expensive inside virtual machine
     1086                 * as it is emulated. The probability that subsequent PICB read
     1087                 * will return different result is high enough to loop till
     1088                 * timeout here.
     1089                 * Same CIV is strict enough condition to be sure that PICB
     1090                 * is valid inside VM on emulated card. */
     1091                if (chip->inside_vm)
     1092                        break;
     1093                if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
    10701094                        break;
    10711095        } while (timeout--);
     
    16841708        {
    16851709                .exclusive = 1,
    1686                 .r =
    1687                  {     
    1688                         {
     1710                .r = {  {
    16891711                                .slots = (1 << AC97_SLOT_PCM_LEFT) |
    16901712                                         (1 << AC97_SLOT_PCM_RIGHT) |
     
    17531775
    17541776static struct ac97_quirk ac97_quirks[] __devinitdata = {
    1755     {
     1777        {
    17561778                .subvendor = 0x0e11,
    17571779                .subdevice = 0x000e,
    17581780                .name = "Compaq Deskpro EN",    /* AD1885 */
    17591781                .type = AC97_TUNE_HP_ONLY
    1760     },
     1782        },
    17611783        {
    17621784                .subvendor = 0x0e11,
     
    17701792                .name = "Compaq Evo D510C",
    17711793                .type = AC97_TUNE_HP_ONLY
    1772         },
    1773     {
     1794        },
     1795        {
    17741796                .subvendor = 0x0e11,
    17751797                .subdevice = 0x0860,
    17761798                .name = "HP/Compaq nx7010",
    17771799                .type = AC97_TUNE_MUTE_LED
    1778     },
     1800        },
    17791801        {
    17801802                .subvendor = 0x1014,
     
    18841906                .name = "Dell Inspiron 6000",
    18851907                .type = AC97_TUNE_HP_MUTE_LED /* cf. Malone #41015 */
     1908        },
     1909        {
     1910                .subvendor = 0x1028,
     1911                .subdevice = 0x0189,
     1912                .name = "Dell Inspiron 9300",
     1913                .type = AC97_TUNE_HP_MUTE_LED
    18861914        },
    18871915        {
     
    20762104                .name = "MSI P4 ATX 645 Ultra",
    20772105                .type = AC97_TUNE_HP_ONLY
     2106        },
     2107        {
     2108                .subvendor = 0x161f,
     2109                .subdevice = 0x202f,
     2110                .name = "Gateway M520",
     2111                .type = AC97_TUNE_INV_EAPD
    20782112        },
    20792113        {
     
    26582692        snd_intel8x0_chip_init(chip, 0);
    26592693        if (request_irq(pci->irq, snd_intel8x0_interrupt,
    2660                         IRQF_SHARED, card->shortname, chip)) {
     2694                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
    26612695                printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
    26622696                       "disabling device\n", pci->irq);
     
    28102844        t *= 1000000;
    28112845        t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
    2812         dprintf(("%s: measured %lu usecs (%lu samples)\n", __func__, t, pos));
     2846        printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
    28132847        if (t == 0) {
    28142848                snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
     
    28312865                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
    28322866      __end:
    2833         dprintf(("intel8x0: clocking to %d\n", chip->ac97_bus->clock));
     2867        printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
    28342868        snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
    28352869}
     
    28372871static struct snd_pci_quirk intel8x0_clock_list[] __devinitdata = {
    28382872        SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000),
     2873        SND_PCI_QUIRK(0x1014, 0x0581, "AD1981B", 48000),
    28392874        SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100),
    28402875        SND_PCI_QUIRK(0x1028, 0x0177, "AD1980", 48000),
     
    29212956        ICH_PCR, ICH_SCR, ICH_SIS_TCR
    29222957};
     2958
     2959static int __devinit snd_intel8x0_inside_vm(struct pci_dev *pci)
     2960{
     2961        int result  = inside_vm;
     2962        char *msg   = NULL;
     2963
     2964        /* check module parameter first (override detection) */
     2965        if (result >= 0) {
     2966                msg = result ? "enable (forced) VM" : "disable (forced) VM";
     2967                goto fini;
     2968        }
     2969
     2970        /* detect KVM and Parallels virtual environments */
     2971        result = kvm_para_available();
     2972#ifdef X86_FEATURE_HYPERVISOR
     2973        result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR);
     2974#endif
     2975        if (!result)
     2976                goto fini;
     2977
     2978        /* check for known (emulated) devices */
     2979        if (pci->subsystem_vendor == 0x1af4 &&
     2980            pci->subsystem_device == 0x1100) {
     2981                /* KVM emulated sound, PCI SSID: 1af4:1100 */
     2982                msg = "enable KVM";
     2983        } else if (pci->subsystem_vendor == 0x1ab8) {
     2984                /* Parallels VM emulated sound, PCI SSID: 1ab8:xxxx */
     2985                msg = "enable Parallels VM";
     2986        } else {
     2987                msg = "disable (unknown or VT-d) VM";
     2988                result = 0;
     2989        }
     2990
     2991fini:
     2992        if (msg != NULL)
     2993                printk(KERN_INFO "intel8x0: %s optimization\n", msg);
     2994
     2995        return result;
     2996}
    29232997
    29242998static int __devinit snd_intel8x0_create(struct snd_card *card,
     
    29893063                chip->xbox = 1;
    29903064
     3065        chip->inside_vm = snd_intel8x0_inside_vm(pci);
     3066
    29913067        if (pci->vendor == PCI_VENDOR_ID_INTEL &&
    29923068            pci->device == PCI_DEVICE_ID_INTEL_440MX)
     
    31173193        /* request irq after initializaing int_sta_mask, etc */
    31183194        if (request_irq(pci->irq, snd_intel8x0_interrupt,
    3119                         IRQF_SHARED, card->shortname, chip)) {
     3195                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
    31203196                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
    31213197                snd_intel8x0_free(chip);
     
    32813357
    32823358static struct pci_driver driver = {
    3283         .name = "Intel ICH",
     3359        .name = KBUILD_MODNAME,
    32843360        .id_table = snd_intel8x0_ids,
    32853361        .probe = snd_intel8x0_probe,
Note: See TracChangeset for help on using the changeset viewer.