Ignore:
Timestamp:
Apr 3, 2017, 4:51:56 PM (8 years ago)
Author:
David Azarewicz
Message:

Merged/reintegrated v2 branch into trunk. Trunk is now v2

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/es1968.c

    r426 r598  
    105105#include <linux/moduleparam.h>
    106106#include <linux/mutex.h>
     107#include <linux/input.h>
    107108
    108109#include <sound/core.h>
     
    229230#define RINGB_SING_BIT_DUAL     0x0040
    230231
    231 /* ****Port Adresses**** */
     232/* ****Port Addresses**** */
    232233
    233234/*   Write & Read */
     
    527528        /* ALSA Stuff */
    528529        struct snd_ac97 *ac97;
    529         struct snd_kcontrol *master_switch; /* for h/w volume control */
    530         struct snd_kcontrol *master_volume;
    531 
    532530        struct snd_rawmidi *rmidi;
    533531
    534532        spinlock_t reg_lock;
    535         spinlock_t ac97_lock;
    536         struct tasklet_struct hwvol_tq;
    537533        unsigned int in_suspend;
    538534
     
    557553        struct gameport *gameport;
    558554#endif
     555
     556#ifdef CONFIG_SND_ES1968_INPUT
     557        struct input_dev *input_dev;
     558        char phys[64];                  /* physical device path */
     559#else
     560        struct snd_kcontrol *master_switch; /* for h/w volume control */
     561        struct snd_kcontrol *master_volume;
     562        spinlock_t ac97_lock;
     563        struct tasklet_struct hwvol_tq;
     564#endif
    559565};
    560566
    561567static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
    562568
    563 static struct pci_device_id snd_es1968_ids[] = {
     569static DEFINE_PCI_DEVICE_TABLE(snd_es1968_ids) = {
    564570        /* Maestro 1 */
    565571        { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO },
     
    642648{
    643649        struct es1968 *chip = ac97->private_data;
     650#ifndef CONFIG_SND_ES1968_INPUT
    644651        unsigned long flags;
     652#endif
    645653
    646654        snd_es1968_ac97_wait(chip);
    647655
    648656        /* Write the bus */
     657#ifndef CONFIG_SND_ES1968_INPUT
    649658        spin_lock_irqsave(&chip->ac97_lock, flags);
     659#endif
    650660        outw(val, chip->io_port + ESM_AC97_DATA);
    651661        /*msleep(1);*/
    652662        outb(reg, chip->io_port + ESM_AC97_INDEX);
    653663        /*msleep(1);*/
     664#ifndef CONFIG_SND_ES1968_INPUT
    654665        spin_unlock_irqrestore(&chip->ac97_lock, flags);
     666#endif
    655667}
    656668
     
    659671        u16 data = 0;
    660672        struct es1968 *chip = ac97->private_data;
     673#ifndef CONFIG_SND_ES1968_INPUT
    661674        unsigned long flags;
     675#endif
    662676
    663677        snd_es1968_ac97_wait(chip);
    664678
     679#ifndef CONFIG_SND_ES1968_INPUT
    665680        spin_lock_irqsave(&chip->ac97_lock, flags);
     681#endif
    666682        outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX);
    667683        /*msleep(1);*/
     
    671687                /*msleep(1);*/
    672688        }
     689#ifndef CONFIG_SND_ES1968_INPUT
    673690        spin_unlock_irqrestore(&chip->ac97_lock, flags);
     691#endif
    674692
    675693        return data;
     
    18841902}
    18851903
    1886 /*
    1887  */
     1904/* The hardware volume works by incrementing / decrementing 2 counters
     1905   (without wrap around) in response to volume button presses and then
     1906   generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7
     1907   of a byte wide register. The meaning of bits 0 and 4 is unknown. */
    18881908static void es1968_update_hw_volume(unsigned long private_data)
    18891909{
    18901910        struct es1968 *chip = (struct es1968 *) private_data;
    18911911        int x, val;
     1912#ifndef CONFIG_SND_ES1968_INPUT
    18921913        unsigned long flags;
     1914#endif
    18931915
    18941916        /* Figure out which volume control button was pushed,
     
    19051927                return;
    19061928
     1929#ifndef CONFIG_SND_ES1968_INPUT
    19071930        if (! chip->master_switch || ! chip->master_volume)
    19081931                return;
     
    19471970        }
    19481971        spin_unlock_irqrestore(&chip->ac97_lock, flags);
     1972#else
     1973        if (!chip->input_dev)
     1974                return;
     1975
     1976        val = 0;
     1977        switch (x) {
     1978        case 0x88:
     1979                /* The counters have not changed, yet we've received a HV
     1980                   interrupt. According to tests run by various people this
     1981                   happens when pressing the mute button. */
     1982                val = KEY_MUTE;
     1983                break;
     1984        case 0xaa:
     1985                /* counters increased by 1 -> volume up */
     1986                val = KEY_VOLUMEUP;
     1987                break;
     1988        case 0x66:
     1989                /* counters decreased by 1 -> volume down */
     1990                val = KEY_VOLUMEDOWN;
     1991                break;
     1992        }
     1993
     1994        if (val) {
     1995                input_report_key(chip->input_dev, val, 1);
     1996                input_sync(chip->input_dev);
     1997                input_report_key(chip->input_dev, val, 0);
     1998                input_sync(chip->input_dev);
     1999        }
     2000#endif
    19492001}
    19502002
     
    19632015
    19642016        if (event & ESM_HWVOL_IRQ)
     2017#ifdef CONFIG_SND_ES1968_INPUT
     2018                es1968_update_hw_volume((unsigned long)chip);
     2019#else
    19652020                tasklet_schedule(&chip->hwvol_tq); /* we'll do this later */
     2021#endif
    19662022
    19672023        /* else ack 'em all, i imagine */
     
    20032059        struct snd_ac97_bus *pbus;
    20042060        struct snd_ac97_template ac97;
     2061#ifndef CONFIG_SND_ES1968_INPUT
    20052062        struct snd_ctl_elem_id elem_id;
     2063#endif
    20062064        int err;
    20072065        static struct snd_ac97_bus_ops ops = {
     
    20192077                return err;
    20202078
     2079#ifndef CONFIG_SND_ES1968_INPUT
    20212080        /* attach master switch / volumes for h/w volume control */
    20222081        memset(&elem_id, 0, sizeof(elem_id));
     
    20282087        strcpy(elem_id.name, "Master Playback Volume");
    20292088        chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
     2089#endif
    20302090
    20312091        return 0;
     
    23512411        if (chip->rmidi)
    23522412                w |= ESM_HIRQ_MPU401;
     2413        outb(w, chip->io_port + 0x1A);
    23532414        outw(w, chip->io_port + ESM_PORT_HOST_IRQ);
    23542415}
     
    24842545#endif
    24852546
     2547#ifdef CONFIG_SND_ES1968_INPUT
     2548static int __devinit snd_es1968_input_register(struct es1968 *chip)
     2549{
     2550        struct input_dev *input_dev;
     2551        int err;
     2552
     2553        input_dev = input_allocate_device();
     2554        if (!input_dev)
     2555                return -ENOMEM;
     2556
     2557        snprintf(chip->phys, sizeof(chip->phys), "pci-%s/input0",
     2558                 pci_name(chip->pci));
     2559
     2560        input_dev->name = chip->card->driver;
     2561        input_dev->phys = chip->phys;
     2562        input_dev->id.bustype = BUS_PCI;
     2563        input_dev->id.vendor  = chip->pci->vendor;
     2564        input_dev->id.product = chip->pci->device;
     2565        input_dev->dev.parent = &chip->pci->dev;
     2566
     2567        __set_bit(EV_KEY, input_dev->evbit);
     2568        __set_bit(KEY_MUTE, input_dev->keybit);
     2569        __set_bit(KEY_VOLUMEDOWN, input_dev->keybit);
     2570        __set_bit(KEY_VOLUMEUP, input_dev->keybit);
     2571
     2572        err = input_register_device(input_dev);
     2573        if (err) {
     2574                input_free_device(input_dev);
     2575                return err;
     2576        }
     2577
     2578        chip->input_dev = input_dev;
     2579        return 0;
     2580}
     2581#endif /* CONFIG_SND_ES1968_INPUT */
     2582
    24862583static int snd_es1968_free(struct es1968 *chip)
    24872584{
     2585#ifdef CONFIG_SND_ES1968_INPUT
     2586        if (chip->input_dev)
     2587                input_unregister_device(chip->input_dev);
     2588#endif
     2589
    24882590        if (chip->io_port) {
    24892591                if (chip->irq >= 0)
     
    24962598                free_irq(chip->irq, chip);
    24972599        snd_es1968_free_gameport(chip);
    2498         chip->master_switch = NULL;
    2499         chip->master_volume = NULL;
    25002600        pci_release_regions(chip->pci);
    25012601        pci_disable_device(chip->pci);
     
    25682668        INIT_LIST_HEAD(&chip->buf_list);
    25692669        INIT_LIST_HEAD(&chip->substream_list);
     2670        mutex_init(&chip->memory_mutex);
     2671#ifndef CONFIG_SND_ES1968_INPUT
    25702672        spin_lock_init(&chip->ac97_lock);
    2571         mutex_init(&chip->memory_mutex);
    25722673        tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip);
     2674#endif
    25732675        chip->card = card;
    25742676        chip->pci = pci;
     
    27232825        snd_es1968_create_gameport(chip, dev);
    27242826
     2827#ifdef CONFIG_SND_ES1968_INPUT
     2828        err = snd_es1968_input_register(chip);
     2829        if (err)
     2830                snd_printk(KERN_WARNING "Input device registration "
     2831                        "failed with error %i", err);
     2832#endif
     2833
    27252834        snd_es1968_start_irq(chip);
    27262835
Note: See TracChangeset for help on using the changeset viewer.