Changeset 598 for GPL/trunk/alsa-kernel/pci/es1968.c
- Timestamp:
- Apr 3, 2017, 4:51:56 PM (8 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
-
Property svn:mergeinfo
set to
/GPL/branches/uniaud32-2.1.x merged eligible
-
Property svn:mergeinfo
set to
-
GPL/trunk/alsa-kernel/pci/es1968.c
r426 r598 105 105 #include <linux/moduleparam.h> 106 106 #include <linux/mutex.h> 107 #include <linux/input.h> 107 108 108 109 #include <sound/core.h> … … 229 230 #define RINGB_SING_BIT_DUAL 0x0040 230 231 231 /* ****Port Ad resses**** */232 /* ****Port Addresses**** */ 232 233 233 234 /* Write & Read */ … … 527 528 /* ALSA Stuff */ 528 529 struct snd_ac97 *ac97; 529 struct snd_kcontrol *master_switch; /* for h/w volume control */530 struct snd_kcontrol *master_volume;531 532 530 struct snd_rawmidi *rmidi; 533 531 534 532 spinlock_t reg_lock; 535 spinlock_t ac97_lock;536 struct tasklet_struct hwvol_tq;537 533 unsigned int in_suspend; 538 534 … … 557 553 struct gameport *gameport; 558 554 #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 559 565 }; 560 566 561 567 static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); 562 568 563 static struct pci_device_id snd_es1968_ids[]= {569 static DEFINE_PCI_DEVICE_TABLE(snd_es1968_ids) = { 564 570 /* Maestro 1 */ 565 571 { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO }, … … 642 648 { 643 649 struct es1968 *chip = ac97->private_data; 650 #ifndef CONFIG_SND_ES1968_INPUT 644 651 unsigned long flags; 652 #endif 645 653 646 654 snd_es1968_ac97_wait(chip); 647 655 648 656 /* Write the bus */ 657 #ifndef CONFIG_SND_ES1968_INPUT 649 658 spin_lock_irqsave(&chip->ac97_lock, flags); 659 #endif 650 660 outw(val, chip->io_port + ESM_AC97_DATA); 651 661 /*msleep(1);*/ 652 662 outb(reg, chip->io_port + ESM_AC97_INDEX); 653 663 /*msleep(1);*/ 664 #ifndef CONFIG_SND_ES1968_INPUT 654 665 spin_unlock_irqrestore(&chip->ac97_lock, flags); 666 #endif 655 667 } 656 668 … … 659 671 u16 data = 0; 660 672 struct es1968 *chip = ac97->private_data; 673 #ifndef CONFIG_SND_ES1968_INPUT 661 674 unsigned long flags; 675 #endif 662 676 663 677 snd_es1968_ac97_wait(chip); 664 678 679 #ifndef CONFIG_SND_ES1968_INPUT 665 680 spin_lock_irqsave(&chip->ac97_lock, flags); 681 #endif 666 682 outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX); 667 683 /*msleep(1);*/ … … 671 687 /*msleep(1);*/ 672 688 } 689 #ifndef CONFIG_SND_ES1968_INPUT 673 690 spin_unlock_irqrestore(&chip->ac97_lock, flags); 691 #endif 674 692 675 693 return data; … … 1884 1902 } 1885 1903 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. */ 1888 1908 static void es1968_update_hw_volume(unsigned long private_data) 1889 1909 { 1890 1910 struct es1968 *chip = (struct es1968 *) private_data; 1891 1911 int x, val; 1912 #ifndef CONFIG_SND_ES1968_INPUT 1892 1913 unsigned long flags; 1914 #endif 1893 1915 1894 1916 /* Figure out which volume control button was pushed, … … 1905 1927 return; 1906 1928 1929 #ifndef CONFIG_SND_ES1968_INPUT 1907 1930 if (! chip->master_switch || ! chip->master_volume) 1908 1931 return; … … 1947 1970 } 1948 1971 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 1949 2001 } 1950 2002 … … 1963 2015 1964 2016 if (event & ESM_HWVOL_IRQ) 2017 #ifdef CONFIG_SND_ES1968_INPUT 2018 es1968_update_hw_volume((unsigned long)chip); 2019 #else 1965 2020 tasklet_schedule(&chip->hwvol_tq); /* we'll do this later */ 2021 #endif 1966 2022 1967 2023 /* else ack 'em all, i imagine */ … … 2003 2059 struct snd_ac97_bus *pbus; 2004 2060 struct snd_ac97_template ac97; 2061 #ifndef CONFIG_SND_ES1968_INPUT 2005 2062 struct snd_ctl_elem_id elem_id; 2063 #endif 2006 2064 int err; 2007 2065 static struct snd_ac97_bus_ops ops = { … … 2019 2077 return err; 2020 2078 2079 #ifndef CONFIG_SND_ES1968_INPUT 2021 2080 /* attach master switch / volumes for h/w volume control */ 2022 2081 memset(&elem_id, 0, sizeof(elem_id)); … … 2028 2087 strcpy(elem_id.name, "Master Playback Volume"); 2029 2088 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id); 2089 #endif 2030 2090 2031 2091 return 0; … … 2351 2411 if (chip->rmidi) 2352 2412 w |= ESM_HIRQ_MPU401; 2413 outb(w, chip->io_port + 0x1A); 2353 2414 outw(w, chip->io_port + ESM_PORT_HOST_IRQ); 2354 2415 } … … 2484 2545 #endif 2485 2546 2547 #ifdef CONFIG_SND_ES1968_INPUT 2548 static 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 2486 2583 static int snd_es1968_free(struct es1968 *chip) 2487 2584 { 2585 #ifdef CONFIG_SND_ES1968_INPUT 2586 if (chip->input_dev) 2587 input_unregister_device(chip->input_dev); 2588 #endif 2589 2488 2590 if (chip->io_port) { 2489 2591 if (chip->irq >= 0) … … 2496 2598 free_irq(chip->irq, chip); 2497 2599 snd_es1968_free_gameport(chip); 2498 chip->master_switch = NULL;2499 chip->master_volume = NULL;2500 2600 pci_release_regions(chip->pci); 2501 2601 pci_disable_device(chip->pci); … … 2568 2668 INIT_LIST_HEAD(&chip->buf_list); 2569 2669 INIT_LIST_HEAD(&chip->substream_list); 2670 mutex_init(&chip->memory_mutex); 2671 #ifndef CONFIG_SND_ES1968_INPUT 2570 2672 spin_lock_init(&chip->ac97_lock); 2571 mutex_init(&chip->memory_mutex);2572 2673 tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip); 2674 #endif 2573 2675 chip->card = card; 2574 2676 chip->pci = pci; … … 2723 2825 snd_es1968_create_gameport(chip, dev); 2724 2826 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 2725 2834 snd_es1968_start_irq(chip); 2726 2835
Note:
See TracChangeset
for help on using the changeset viewer.