Changeset 598 for GPL/trunk/alsa-kernel/pci/maestro3.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/maestro3.c
r426 r598 42 42 #include <linux/moduleparam.h> 43 43 #include <linux/firmware.h> 44 #include <linux/input.h> 44 45 #include <sound/core.h> 45 46 #include <sound/info.h> … … 849 850 850 851 spinlock_t reg_lock; 852 853 #ifdef CONFIG_SND_MAESTRO3_INPUT 854 struct input_dev *input_dev; 855 char phys[64]; /* physical device path */ 856 #else 851 857 spinlock_t ac97_lock; 852 853 858 struct snd_kcontrol *master_switch; 854 859 struct snd_kcontrol *master_volume; 855 860 struct tasklet_struct hwvol_tq; 861 #endif 862 863 unsigned int in_suspend; 856 864 857 865 #ifdef CONFIG_PM … … 866 874 * pci ids 867 875 */ 868 static struct pci_device_id snd_m3_ids[]= {876 static DEFINE_PCI_DEVICE_TABLE(snd_m3_ids) = { 869 877 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, 870 878 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, … … 889 897 890 898 static struct snd_pci_quirk m3_amp_quirk_list[] __devinitdata = { 899 SND_PCI_QUIRK(0x0E11, 0x0094, "Compaq Evo N600c", 0x0c), 891 900 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d), 892 901 SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d), … … 1601 1610 } 1602 1611 1612 /* The m3's hardware volume works by incrementing / decrementing 2 counters 1613 (without wrap around) in response to volume button presses and then 1614 generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7 1615 of a byte wide register. The meaning of bits 0 and 4 is unknown. */ 1603 1616 static void snd_m3_update_hw_volume(unsigned long private_data) 1604 1617 { 1605 1618 struct snd_m3 *chip = (struct snd_m3 *) private_data; 1606 1619 int x, val; 1620 #ifndef CONFIG_SND_MAESTRO3_INPUT 1607 1621 unsigned long flags; 1622 #endif 1608 1623 1609 1624 /* Figure out which volume control button was pushed, … … 1612 1627 x = inb(chip->iobase + SHADOW_MIX_REG_VOICE) & 0xee; 1613 1628 1614 /* Reset the volume control registers. */ 1629 /* Reset the volume counters to 4. Tests on the allegro integrated 1630 into a Compaq N600C laptop, have revealed that: 1631 1) Writing any value will result in the 2 counters being reset to 1632 4 so writing 0x88 is not strictly necessary 1633 2) Writing to any of the 4 involved registers will reset all 4 1634 of them (and reading them always returns the same value for all 1635 of them) 1636 It could be that a maestro deviates from this, so leave the code 1637 as is. */ 1615 1638 outb(0x88, chip->iobase + SHADOW_MIX_REG_VOICE); 1616 1639 outb(0x88, chip->iobase + HW_VOL_COUNTER_VOICE); … … 1618 1641 outb(0x88, chip->iobase + HW_VOL_COUNTER_MASTER); 1619 1642 1643 /* Ignore spurious HV interrupts during suspend / resume, this avoids 1644 mistaking them for a mute button press. */ 1645 if (chip->in_suspend) 1646 return; 1647 1648 #ifndef CONFIG_SND_MAESTRO3_INPUT 1620 1649 if (!chip->master_switch || !chip->master_volume) 1621 1650 return; … … 1627 1656 switch (x) { 1628 1657 case 0x88: 1629 /* mute */ 1658 /* The counters have not changed, yet we've received a HV 1659 interrupt. According to tests run by various people this 1660 happens when pressing the mute button. */ 1630 1661 val ^= 0x8000; 1631 1662 chip->ac97->regs[AC97_MASTER_VOL] = val; … … 1636 1667 break; 1637 1668 case 0xaa: 1638 /* volume up */1669 /* counters increased by 1 -> volume up */ 1639 1670 if ((val & 0x7f) > 0) 1640 1671 val--; … … 1648 1679 break; 1649 1680 case 0x66: 1650 /* volume down */1681 /* counters decreased by 1 -> volume down */ 1651 1682 if ((val & 0x7f) < 0x1f) 1652 1683 val++; … … 1661 1692 } 1662 1693 spin_unlock_irqrestore(&chip->ac97_lock, flags); 1694 #else 1695 if (!chip->input_dev) 1696 return; 1697 1698 val = 0; 1699 switch (x) { 1700 case 0x88: 1701 /* The counters have not changed, yet we've received a HV 1702 interrupt. According to tests run by various people this 1703 happens when pressing the mute button. */ 1704 val = KEY_MUTE; 1705 break; 1706 case 0xaa: 1707 /* counters increased by 1 -> volume up */ 1708 val = KEY_VOLUMEUP; 1709 break; 1710 case 0x66: 1711 /* counters decreased by 1 -> volume down */ 1712 val = KEY_VOLUMEDOWN; 1713 break; 1714 } 1715 1716 if (val) { 1717 input_report_key(chip->input_dev, val, 1); 1718 input_sync(chip->input_dev); 1719 input_report_key(chip->input_dev, val, 0); 1720 input_sync(chip->input_dev); 1721 } 1722 #endif 1663 1723 } 1664 1724 … … 1675 1735 1676 1736 if (status & HV_INT_PENDING) 1737 #ifdef CONFIG_SND_MAESTRO3_INPUT 1738 snd_m3_update_hw_volume((unsigned long)chip); 1739 #else 1677 1740 tasklet_schedule(&chip->hwvol_tq); 1741 #endif 1678 1742 1679 1743 /* … … 1941 2005 { 1942 2006 struct snd_m3 *chip = ac97->private_data; 2007 #ifndef CONFIG_SND_MAESTRO3_INPUT 1943 2008 unsigned long flags; 2009 #endif 1944 2010 unsigned short data = 0xffff; 1945 2011 1946 2012 if (snd_m3_ac97_wait(chip)) 1947 2013 goto fail; 2014 #ifndef CONFIG_SND_MAESTRO3_INPUT 1948 2015 spin_lock_irqsave(&chip->ac97_lock, flags); 2016 #endif 1949 2017 snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); 1950 2018 if (snd_m3_ac97_wait(chip)) … … 1952 2020 data = snd_m3_inw(chip, CODEC_DATA); 1953 2021 fail_unlock: 2022 #ifndef CONFIG_SND_MAESTRO3_INPUT 1954 2023 spin_unlock_irqrestore(&chip->ac97_lock, flags); 2024 #endif 1955 2025 fail: 1956 2026 return data; … … 1961 2031 { 1962 2032 struct snd_m3 *chip = ac97->private_data; 2033 #ifndef CONFIG_SND_MAESTRO3_INPUT 1963 2034 unsigned long flags; 2035 #endif 1964 2036 1965 2037 if (snd_m3_ac97_wait(chip)) 1966 2038 return; 2039 #ifndef CONFIG_SND_MAESTRO3_INPUT 1967 2040 spin_lock_irqsave(&chip->ac97_lock, flags); 2041 #endif 1968 2042 snd_m3_outw(chip, val, CODEC_DATA); 1969 2043 snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); 2044 #ifndef CONFIG_SND_MAESTRO3_INPUT 1970 2045 spin_unlock_irqrestore(&chip->ac97_lock, flags); 2046 #endif 1971 2047 } 1972 2048 … … 2075 2151 struct snd_ac97_bus *pbus; 2076 2152 struct snd_ac97_template ac97; 2153 #ifndef CONFIG_SND_MAESTRO3_INPUT 2077 2154 struct snd_ctl_elem_id elem_id; 2155 #endif 2078 2156 int err; 2079 2157 static struct snd_ac97_bus_ops ops = { … … 2095 2173 snd_ac97_write(chip->ac97, AC97_PCM, 0); 2096 2174 2175 #ifndef CONFIG_SND_MAESTRO3_INPUT 2097 2176 memset(&elem_id, 0, sizeof(elem_id)); 2098 2177 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; … … 2103 2182 strcpy(elem_id.name, "Master Playback Volume"); 2104 2183 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id); 2184 #endif 2105 2185 2106 2186 return 0; … … 2368 2448 if (chip->hv_config & HV_CTRL_ENABLE) 2369 2449 val |= HV_INT_ENABLE; 2450 outb(val, chip->iobase + HOST_INT_STATUS); 2370 2451 outw(val, io + HOST_INT_CTRL); 2371 2452 outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, … … 2381 2462 struct m3_dma *s; 2382 2463 int i; 2464 2465 #ifdef CONFIG_SND_MAESTRO3_INPUT 2466 if (chip->input_dev) 2467 input_unregister_device(chip->input_dev); 2468 #endif 2383 2469 2384 2470 if (chip->substreams) { … … 2429 2515 return 0; 2430 2516 2517 chip->in_suspend = 1; 2431 2518 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2432 2519 snd_pcm_suspend_all(chip->pcm); … … 2502 2589 2503 2590 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2591 chip->in_suspend = 0; 2504 2592 return 0; 2505 2593 } 2506 2594 #endif /* CONFIG_PM */ 2507 2595 2596 #ifdef CONFIG_SND_MAESTRO3_INPUT 2597 static int __devinit snd_m3_input_register(struct snd_m3 *chip) 2598 { 2599 struct input_dev *input_dev; 2600 int err; 2601 2602 input_dev = input_allocate_device(); 2603 if (!input_dev) 2604 return -ENOMEM; 2605 2606 snprintf(chip->phys, sizeof(chip->phys), "pci-%s/input0", 2607 pci_name(chip->pci)); 2608 2609 input_dev->name = chip->card->driver; 2610 input_dev->phys = chip->phys; 2611 input_dev->id.bustype = BUS_PCI; 2612 input_dev->id.vendor = chip->pci->vendor; 2613 input_dev->id.product = chip->pci->device; 2614 input_dev->dev.parent = &chip->pci->dev; 2615 2616 __set_bit(EV_KEY, input_dev->evbit); 2617 __set_bit(KEY_MUTE, input_dev->keybit); 2618 __set_bit(KEY_VOLUMEDOWN, input_dev->keybit); 2619 __set_bit(KEY_VOLUMEUP, input_dev->keybit); 2620 2621 err = input_register_device(input_dev); 2622 if (err) { 2623 input_free_device(input_dev); 2624 return err; 2625 } 2626 2627 chip->input_dev = input_dev; 2628 return 0; 2629 } 2630 #endif /* CONFIG_INPUT */ 2508 2631 2509 2632 /* … … 2549 2672 2550 2673 spin_lock_init(&chip->reg_lock); 2674 #ifndef CONFIG_SND_MAESTRO3_INPUT 2551 2675 spin_lock_init(&chip->ac97_lock); 2676 #endif 2552 2677 2553 2678 switch (pci->device) { … … 2636 2761 snd_m3_hv_init(chip); 2637 2762 2763 #ifndef CONFIG_SND_MAESTRO3_INPUT 2638 2764 tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip); 2765 #endif 2639 2766 2640 2767 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, … … 2668 2795 if ((err = snd_m3_pcm(chip, 0)) < 0) 2669 2796 return err; 2670 2797 2798 #ifdef CONFIG_SND_MAESTRO3_INPUT 2799 if (chip->hv_config & HV_CTRL_ENABLE) { 2800 err = snd_m3_input_register(chip); 2801 if (err) 2802 snd_printk(KERN_WARNING "Input device registration " 2803 "failed with error %i", err); 2804 } 2805 #endif 2806 2671 2807 snd_m3_enable_ints(chip); 2672 2808 snd_m3_assp_continue(chip);
Note:
See TracChangeset
for help on using the changeset viewer.