Changeset 679 for GPL/trunk/alsa-kernel/pci/maestro3.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/maestro3.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for ESS Maestro3/Allegro (ES1988) soundcards. … … 7 8 * OSS/Free by Zach Brown. Many thanks to Zach! 8 9 * 9 * This program is free software; you can redistribute it and/or modify10 * it under the terms of the GNU General Public License as published by11 * the Free Software Foundation; either version 2 of the License, or12 * (at your option) any later version.13 *14 * This program is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU General Public License for more details.18 *19 * You should have received a copy of the GNU General Public License20 * along with this program; if not, write to the Free Software21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA22 *23 *24 10 * ChangeLog: 25 11 * Aug. 27, 2001 26 12 * - Fixed deadlock on capture 27 13 * - Added Canyon3D-2 support by Rob Riggs <rob@pangalactic.org> 28 *29 14 */ 30 15 31 16 #define CARD_NAME "ESS Maestro3/Allegro/Canyon3D-2" 32 17 #define DRIVER_NAME "Maestro3" 33 34 #include <asm/io.h> 18 #ifdef TARGET_OS2 19 #define KBUILD_MODNAME "Maestro3" 20 #endif 21 22 #include <linux/io.h> 35 23 #include <linux/delay.h> 36 24 #include <linux/interrupt.h> … … 40 28 #include <linux/slab.h> 41 29 #include <linux/vmalloc.h> 42 #include <linux/module param.h>30 #include <linux/module.h> 43 31 #include <linux/firmware.h> 44 32 #include <linux/input.h> … … 65 53 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 66 54 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 67 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */55 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */ 68 56 #ifndef TARGET_OS2 69 static intexternal_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};57 static bool external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 70 58 static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 71 59 #else … … 366 354 #define DSP2HOST_REQ_TIMER 0x04 367 355 368 /* AC97 registers */369 /* XXX fix this crap up */370 /*#define AC97_RESET 0x00*/371 372 #define AC97_VOL_MUTE_B 0x8000373 #define AC97_VOL_M 0x1F374 #define AC97_LEFT_VOL_S 8375 376 #define AC97_MASTER_VOL 0x02377 #define AC97_LINE_LEVEL_VOL 0x04378 #define AC97_MASTER_MONO_VOL 0x06379 #define AC97_PC_BEEP_VOL 0x0A380 #define AC97_PC_BEEP_VOL_M 0x0F381 #define AC97_SROUND_MASTER_VOL 0x38382 #define AC97_PC_BEEP_VOL_S 1383 384 /*#define AC97_PHONE_VOL 0x0C385 #define AC97_MIC_VOL 0x0E*/386 #define AC97_MIC_20DB_ENABLE 0x40387 388 /*#define AC97_LINEIN_VOL 0x10389 #define AC97_CD_VOL 0x12390 #define AC97_VIDEO_VOL 0x14391 #define AC97_AUX_VOL 0x16*/392 #define AC97_PCM_OUT_VOL 0x18393 /*#define AC97_RECORD_SELECT 0x1A*/394 #define AC97_RECORD_MIC 0x00395 #define AC97_RECORD_CD 0x01396 #define AC97_RECORD_VIDEO 0x02397 #define AC97_RECORD_AUX 0x03398 #define AC97_RECORD_MONO_MUX 0x02399 #define AC97_RECORD_DIGITAL 0x03400 #define AC97_RECORD_LINE 0x04401 #define AC97_RECORD_STEREO 0x05402 #define AC97_RECORD_MONO 0x06403 #define AC97_RECORD_PHONE 0x07404 405 /*#define AC97_RECORD_GAIN 0x1C*/406 #define AC97_RECORD_VOL_M 0x0F407 408 /*#define AC97_GENERAL_PURPOSE 0x20*/409 #define AC97_POWER_DOWN_CTRL 0x26410 #define AC97_ADC_READY 0x0001411 #define AC97_DAC_READY 0x0002412 #define AC97_ANALOG_READY 0x0004413 #define AC97_VREF_ON 0x0008414 #define AC97_PR0 0x0100415 #define AC97_PR1 0x0200416 #define AC97_PR2 0x0400417 #define AC97_PR3 0x0800418 #define AC97_PR4 0x1000419 420 #define AC97_RESERVED1 0x28421 422 #define AC97_VENDOR_TEST 0x5A423 424 #define AC97_CLOCK_DELAY 0x5C425 #define AC97_LINEOUT_MUX_SEL 0x0001426 #define AC97_MONO_MUX_SEL 0x0002427 #define AC97_CLOCK_DELAY_SEL 0x1F428 #define AC97_DAC_CDS_SHIFT 6429 #define AC97_ADC_CDS_SHIFT 11430 431 #define AC97_MULTI_CHANNEL_SEL 0x74432 433 /*#define AC97_VENDOR_ID1 0x7C434 #define AC97_VENDOR_ID2 0x7E*/435 436 356 /* 437 357 * ASSP control regs … … 855 775 char phys[64]; /* physical device path */ 856 776 #else 857 spinlock_t ac97_lock;858 777 struct snd_kcontrol *master_switch; 859 778 struct snd_kcontrol *master_volume; 860 struct tasklet_struct hwvol_tq;861 779 #endif 780 struct work_struct hwvol_work; 862 781 863 782 unsigned int in_suspend; 864 783 865 #ifdef CONFIG_PM 784 #ifdef CONFIG_PM_SLEEP 866 785 u16 *suspend_mem; 867 786 #endif … … 874 793 * pci ids 875 794 */ 876 static DEFINE_PCI_DEVICE_TABLE(snd_m3_ids)= {795 static const struct pci_device_id snd_m3_ids[] = { 877 796 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, 878 797 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, … … 896 815 MODULE_DEVICE_TABLE(pci, snd_m3_ids); 897 816 898 static struct snd_pci_quirk m3_amp_quirk_list[] __devinitdata= {817 static const struct snd_pci_quirk m3_amp_quirk_list[] = { 899 818 SND_PCI_QUIRK(0x0E11, 0x0094, "Compaq Evo N600c", 0x0c), 900 819 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d), … … 905 824 }; 906 825 907 static struct snd_pci_quirk m3_irda_quirk_list[] __devinitdata= {826 static const struct snd_pci_quirk m3_irda_quirk_list[] = { 908 827 SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1), 909 828 SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1), … … 913 832 914 833 /* hardware volume quirks */ 915 static struct snd_pci_quirk m3_hv_quirk_list[] __devinitdata= {834 static const struct snd_pci_quirk m3_hv_quirk_list[] = { 916 835 /* Allegro chips */ 917 836 SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), … … 991 910 992 911 /* HP Omnibook quirks */ 993 static struct snd_pci_quirk m3_omnibook_quirk_list[] __devinitdata= {912 static const struct snd_pci_quirk m3_omnibook_quirk_list[] = { 994 913 SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */ 995 914 SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */ … … 1470 1389 { 1471 1390 struct m3_dma *s = substream->runtime->private_data; 1472 int err; 1473 1474 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 1475 return err; 1391 1476 1392 /* set buffer address */ 1477 1393 s->buffer_addr = substream->runtime->dma_addr; 1478 1394 if (s->buffer_addr & 0x3) { 1479 snd_printk(KERN_ERR"oh my, not aligned\n");1395 dev_err(substream->pcm->card->dev, "oh my, not aligned\n"); 1480 1396 s->buffer_addr = s->buffer_addr & ~0x3; 1481 1397 } … … 1490 1406 return 0; 1491 1407 s = substream->runtime->private_data; 1492 snd_pcm_lib_free_pages(substream);1493 1408 s->buffer_addr = 0; 1494 1409 return 0; … … 1614 1529 generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7 1615 1530 of a byte wide register. The meaning of bits 0 and 4 is unknown. */ 1616 static void snd_m3_update_hw_volume( unsigned long private_data)1617 { 1618 struct snd_m3 *chip = (struct snd_m3 *) private_data;1531 static void snd_m3_update_hw_volume(struct work_struct *work) 1532 { 1533 struct snd_m3 *chip = container_of(work, struct snd_m3, hwvol_work); 1619 1534 int x, val; 1620 #ifndef CONFIG_SND_MAESTRO3_INPUT1621 unsigned long flags;1622 #endif1623 1535 1624 1536 /* Figure out which volume control button was pushed, … … 1650 1562 return; 1651 1563 1652 /* FIXME: we can't call snd_ac97_* functions since here is in tasklet. */ 1653 spin_lock_irqsave(&chip->ac97_lock, flags); 1654 1655 val = chip->ac97->regs[AC97_MASTER_VOL]; 1564 val = snd_ac97_read(chip->ac97, AC97_MASTER); 1656 1565 switch (x) { 1657 1566 case 0x88: … … 1660 1569 happens when pressing the mute button. */ 1661 1570 val ^= 0x8000; 1662 chip->ac97->regs[AC97_MASTER_VOL] = val;1663 outw(val, chip->iobase + CODEC_DATA);1664 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);1665 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,1666 &chip->master_switch->id);1667 1571 break; 1668 1572 case 0xaa: … … 1672 1576 if ((val & 0x7f00) > 0) 1673 1577 val -= 0x0100; 1674 chip->ac97->regs[AC97_MASTER_VOL] = val;1675 outw(val, chip->iobase + CODEC_DATA);1676 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);1677 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,1678 &chip->master_volume->id);1679 1578 break; 1680 1579 case 0x66: … … 1684 1583 if ((val & 0x7f00) < 0x1f00) 1685 1584 val += 0x0100; 1686 chip->ac97->regs[AC97_MASTER_VOL] = val;1687 outw(val, chip->iobase + CODEC_DATA);1688 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);1585 break; 1586 } 1587 if (snd_ac97_update(chip->ac97, AC97_MASTER, val)) 1689 1588 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 1690 &chip->master_volume->id); 1691 break; 1692 } 1693 spin_unlock_irqrestore(&chip->ac97_lock, flags); 1589 &chip->master_switch->id); 1694 1590 #else 1695 1591 if (!chip->input_dev) … … 1735 1631 1736 1632 if (status & HV_INT_PENDING) 1737 #ifdef CONFIG_SND_MAESTRO3_INPUT 1738 snd_m3_update_hw_volume((unsigned long)chip); 1739 #else 1740 tasklet_schedule(&chip->hwvol_tq); 1741 #endif 1633 schedule_work(&chip->hwvol_work); 1742 1634 1743 1635 /* … … 1778 1670 */ 1779 1671 1780 static struct snd_pcm_hardware snd_m3_playback =1672 static const struct snd_pcm_hardware snd_m3_playback = 1781 1673 { 1782 1674 .info = (SNDRV_PCM_INFO_MMAP | … … 1799 1691 }; 1800 1692 1801 static struct snd_pcm_hardware snd_m3_capture =1693 static const struct snd_pcm_hardware snd_m3_capture = 1802 1694 { 1803 1695 .info = (SNDRV_PCM_INFO_MMAP | … … 1931 1823 */ 1932 1824 1933 static struct snd_pcm_ops snd_m3_playback_ops = {1825 static const struct snd_pcm_ops snd_m3_playback_ops = { 1934 1826 .open = snd_m3_playback_open, 1935 1827 .close = snd_m3_playback_close, 1936 .ioctl = snd_pcm_lib_ioctl,1937 1828 .hw_params = snd_m3_pcm_hw_params, 1938 1829 .hw_free = snd_m3_pcm_hw_free, … … 1942 1833 }; 1943 1834 1944 static struct snd_pcm_ops snd_m3_capture_ops = {1835 static const struct snd_pcm_ops snd_m3_capture_ops = { 1945 1836 .open = snd_m3_capture_open, 1946 1837 .close = snd_m3_capture_close, 1947 .ioctl = snd_pcm_lib_ioctl,1948 1838 .hw_params = snd_m3_pcm_hw_params, 1949 1839 .hw_free = snd_m3_pcm_hw_free, … … 1953 1843 }; 1954 1844 1955 static int __devinit1845 static int 1956 1846 snd_m3_pcm(struct snd_m3 * chip, int device) 1957 1847 { … … 1972 1862 chip->pcm = pcm; 1973 1863 1974 snd_pcm_ lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,1975 snd_dma_pci_data(chip->pci), 64*1024, 64*1024);1864 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1865 &chip->pci->dev, 64*1024, 64*1024); 1976 1866 1977 1867 return 0; … … 1997 1887 } while (i-- > 0); 1998 1888 1999 snd_printk(KERN_ERR"ac97 serial bus busy\n");1889 dev_err(chip->card->dev, "ac97 serial bus busy\n"); 2000 1890 return 1; 2001 1891 } … … 2005 1895 { 2006 1896 struct snd_m3 *chip = ac97->private_data; 2007 #ifndef CONFIG_SND_MAESTRO3_INPUT2008 unsigned long flags;2009 #endif2010 1897 unsigned short data = 0xffff; 2011 1898 2012 1899 if (snd_m3_ac97_wait(chip)) 2013 1900 goto fail; 2014 #ifndef CONFIG_SND_MAESTRO3_INPUT2015 spin_lock_irqsave(&chip->ac97_lock, flags);2016 #endif2017 1901 snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); 2018 1902 if (snd_m3_ac97_wait(chip)) 2019 goto fail _unlock;1903 goto fail; 2020 1904 data = snd_m3_inw(chip, CODEC_DATA); 2021 fail_unlock:2022 #ifndef CONFIG_SND_MAESTRO3_INPUT2023 spin_unlock_irqrestore(&chip->ac97_lock, flags);2024 #endif2025 1905 fail: 2026 1906 return data; … … 2031 1911 { 2032 1912 struct snd_m3 *chip = ac97->private_data; 2033 #ifndef CONFIG_SND_MAESTRO3_INPUT2034 unsigned long flags;2035 #endif2036 1913 2037 1914 if (snd_m3_ac97_wait(chip)) 2038 1915 return; 2039 #ifndef CONFIG_SND_MAESTRO3_INPUT2040 spin_lock_irqsave(&chip->ac97_lock, flags);2041 #endif2042 1916 snd_m3_outw(chip, val, CODEC_DATA); 2043 1917 snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); 2044 #ifndef CONFIG_SND_MAESTRO3_INPUT 2045 spin_unlock_irqrestore(&chip->ac97_lock, flags); 2046 #endif 2047 } 2048 2049 2050 static void snd_m3_remote_codec_config(int io, int isremote) 2051 { 1918 /* 1919 * Workaround for buggy ES1988 integrated AC'97 codec. It remains silent 1920 * until the MASTER volume or mute is touched (alsactl restore does not 1921 * work). 1922 */ 1923 if (ac97->id == 0x45838308 && reg == AC97_MASTER) { 1924 snd_m3_ac97_wait(chip); 1925 snd_m3_outw(chip, val, CODEC_DATA); 1926 snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); 1927 } 1928 } 1929 1930 1931 static void snd_m3_remote_codec_config(struct snd_m3 *chip, int isremote) 1932 { 1933 int io = chip->iobase; 1934 u16 tmp; 1935 2052 1936 isremote = isremote ? 1 : 0; 2053 1937 2054 outw((inw(io + RING_BUS_CTRL_B) & ~SECOND_CODEC_ID_MASK) | isremote, 2055 io + RING_BUS_CTRL_B); 1938 tmp = inw(io + RING_BUS_CTRL_B) & ~SECOND_CODEC_ID_MASK; 1939 /* enable dock on Dell Latitude C810 */ 1940 if (chip->pci->subsystem_vendor == 0x1028 && 1941 chip->pci->subsystem_device == 0x00e5) 1942 tmp |= M3I_DOCK_ENABLE; 1943 outw(tmp | isremote, io + RING_BUS_CTRL_B); 2056 1944 outw((inw(io + SDO_OUT_DEST_CTRL) & ~COMMAND_ADDR_OUT) | isremote, 2057 1945 io + SDO_OUT_DEST_CTRL); … … 2105 1993 dir |= 0x10; /* assuming pci bus master? */ 2106 1994 2107 snd_m3_remote_codec_config( io, 0);1995 snd_m3_remote_codec_config(chip, 0); 2108 1996 2109 1997 outw(IO_SRAM_ENABLE, io + RING_BUS_CTRL_A); … … 2131 2019 delay2 += 100; 2132 2020 2133 snd_printd("maestro3: retrying codec reset with delays of %d and %d ms\n", 2021 dev_dbg(chip->card->dev, 2022 "retrying codec reset with delays of %d and %d ms\n", 2134 2023 delay1, delay2); 2135 2024 } … … 2147 2036 } 2148 2037 2149 static int __devinitsnd_m3_mixer(struct snd_m3 *chip)2038 static int snd_m3_mixer(struct snd_m3 *chip) 2150 2039 { 2151 2040 struct snd_ac97_bus *pbus; … … 2155 2044 #endif 2156 2045 int err; 2157 static struct snd_ac97_bus_ops ops = {2046 static const struct snd_ac97_bus_ops ops = { 2158 2047 .write = snd_m3_ac97_write, 2159 2048 .read = snd_m3_ac97_read, … … 2201 2090 { 2202 2091 unsigned int i; 2203 const u16 *data;2092 const __le16 *data; 2204 2093 2205 2094 /* zero kernel data */ … … 2219 2108 2220 2109 /* write kernel into code memory.. */ 2221 data = (const u16 *)chip->assp_kernel_image->data;2110 data = (const __le16 *)chip->assp_kernel_image->data; 2222 2111 for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { 2223 2112 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, … … 2232 2121 * need vectors, so we won't bother with them.. 2233 2122 */ 2234 data = (const u16 *)chip->assp_minisrc_image->data;2123 data = (const __le16 *)chip->assp_minisrc_image->data; 2235 2124 for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { 2236 2125 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, … … 2289 2178 2290 2179 2291 static int __devinitsnd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int index)2180 static int snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int index) 2292 2181 { 2293 2182 int data_bytes = 2 * ( MINISRC_TMP_BUFFER_SIZE / 2 + … … 2310 2199 2311 2200 if ((address + (data_bytes/2)) >= 0x1c00) { 2312 snd_printk(KERN_ERR "no memory for %d bytes at ind %d (addr 0x%x)\n", 2201 dev_err(chip->card->dev, 2202 "no memory for %d bytes at ind %d (addr 0x%x)\n", 2313 2203 data_bytes, index, address); 2314 2204 return -ENOMEM; … … 2463 2353 int i; 2464 2354 2355 cancel_work_sync(&chip->hwvol_work); 2465 2356 #ifdef CONFIG_SND_MAESTRO3_INPUT 2466 2357 if (chip->input_dev) … … 2483 2374 } 2484 2375 2485 #ifdef CONFIG_PM 2376 #ifdef CONFIG_PM_SLEEP 2486 2377 vfree(chip->suspend_mem); 2487 2378 #endif … … 2505 2396 * APM support 2506 2397 */ 2507 #ifdef CONFIG_PM 2508 static int m3_suspend(struct pci_dev *pci, pm_message_t state)2509 { 2510 struct snd_card *card = pci_get_drvdata(pci);2398 #ifdef CONFIG_PM_SLEEP 2399 static int m3_suspend(struct device *dev) 2400 { 2401 struct snd_card *card = dev_get_drvdata(dev); 2511 2402 struct snd_m3 *chip = card->private_data; 2512 2403 int i, dsp_index; … … 2516 2407 2517 2408 chip->in_suspend = 1; 2409 cancel_work_sync(&chip->hwvol_work); 2518 2410 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2519 snd_pcm_suspend_all(chip->pcm);2520 2411 snd_ac97_suspend(chip->ac97); 2521 2412 … … 2532 2423 chip->suspend_mem[dsp_index++] = 2533 2424 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); 2534 2535 pci_disable_device(pci);2536 pci_save_state(pci);2537 pci_set_power_state(pci, pci_choose_state(pci, state));2538 2425 return 0; 2539 2426 } 2540 2427 2541 static int m3_resume(struct pci_dev *pci)2542 { 2543 struct snd_card *card = pci_get_drvdata(pci);2428 static int m3_resume(struct device *dev) 2429 { 2430 struct snd_card *card = dev_get_drvdata(dev); 2544 2431 struct snd_m3 *chip = card->private_data; 2545 2432 int i, dsp_index; … … 2547 2434 if (chip->suspend_mem == NULL) 2548 2435 return 0; 2549 2550 pci_set_power_state(pci, PCI_D0);2551 pci_restore_state(pci);2552 if (pci_enable_device(pci) < 0) {2553 printk(KERN_ERR "maestor3: pci_enable_device failed, "2554 "disabling device\n");2555 snd_card_disconnect(card);2556 return -EIO;2557 }2558 pci_set_master(pci);2559 2436 2560 2437 /* first lets just bring everything back. .*/ … … 2592 2469 return 0; 2593 2470 } 2594 #endif /* CONFIG_PM */ 2471 2472 static SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume); 2473 #define M3_PM_OPS &m3_pm 2474 #else 2475 #define M3_PM_OPS NULL 2476 #endif /* CONFIG_PM_SLEEP */ 2595 2477 2596 2478 #ifdef CONFIG_SND_MAESTRO3_INPUT 2597 static int __devinitsnd_m3_input_register(struct snd_m3 *chip)2479 static int snd_m3_input_register(struct snd_m3 *chip) 2598 2480 { 2599 2481 struct input_dev *input_dev; … … 2639 2521 } 2640 2522 2641 static int __devinit2523 static int 2642 2524 snd_m3_create(struct snd_card *card, struct pci_dev *pci, 2643 2525 int enable_amp, … … 2648 2530 int i, err; 2649 2531 const struct snd_pci_quirk *quirk; 2650 static struct snd_device_ops ops = {2532 static const struct snd_device_ops ops = { 2651 2533 .dev_free = snd_m3_dev_free, 2652 2534 }; … … 2658 2540 2659 2541 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2660 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 2661 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 2662 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2542 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 || 2543 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) { 2544 dev_err(card->dev, 2545 "architecture does not support 28bit PCI busmaster DMA\n"); 2663 2546 pci_disable_device(pci); 2664 2547 return -ENXIO; … … 2672 2555 2673 2556 spin_lock_init(&chip->reg_lock); 2674 #ifndef CONFIG_SND_MAESTRO3_INPUT2675 spin_lock_init(&chip->ac97_lock);2676 #endif2677 2557 2678 2558 switch (pci->device) { … … 2688 2568 chip->pci = pci; 2689 2569 chip->irq = -1; 2570 INIT_WORK(&chip->hwvol_work, snd_m3_update_hw_volume); 2690 2571 2691 2572 chip->external_amp = enable_amp; … … 2695 2576 quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list); 2696 2577 if (quirk) { 2697 #ifndef TARGET_OS2 2698 snd_printdd(KERN_INFO "maestro3: set amp-gpio " 2699 "for '%s'\n", quirk->name); 2700 #endif 2578 dev_info(card->dev, "set amp-gpio for '%s'\n", 2579 snd_pci_quirk_name(quirk)); 2701 2580 chip->amp_gpio = quirk->value; 2702 2581 } else if (chip->allegro_flag) … … 2708 2587 quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list); 2709 2588 if (quirk) { 2710 #ifndef TARGET_OS2 2711 snd_printdd(KERN_INFO "maestro3: enabled irda workaround " 2712 "for '%s'\n", quirk->name); 2713 #endif 2589 dev_info(card->dev, "enabled irda workaround for '%s'\n", 2590 snd_pci_quirk_name(quirk)); 2714 2591 chip->irda_workaround = 1; 2715 2592 } … … 2731 2608 err = request_firmware(&chip->assp_kernel_image, 2732 2609 "ess/maestro3_assp_kernel.fw", &pci->dev); 2733 if (err < 0) { 2734 snd_m3_free(chip); 2735 return err; 2736 } 2610 if (err < 0) 2611 goto free_chip; 2737 2612 2738 2613 err = request_firmware(&chip->assp_minisrc_image, 2739 2614 "ess/maestro3_assp_minisrc.fw", &pci->dev); 2740 if (err < 0) { 2741 snd_m3_free(chip); 2742 return err; 2743 } 2744 2745 if ((err = pci_request_regions(pci, card->driver)) < 0) { 2746 snd_m3_free(chip); 2747 return err; 2748 } 2615 if (err < 0) 2616 goto free_chip; 2617 2618 err = pci_request_regions(pci, card->driver); 2619 if (err < 0) 2620 goto free_chip; 2621 2749 2622 chip->iobase = pci_resource_start(pci, 0); 2750 2623 … … 2761 2634 snd_m3_hv_init(chip); 2762 2635 2763 #ifndef CONFIG_SND_MAESTRO3_INPUT 2764 tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip); 2636 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, 2637 KBUILD_MODNAME, chip)) { 2638 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2639 err = -ENOMEM; 2640 goto free_chip; 2641 } 2642 chip->irq = pci->irq; 2643 card->sync_irq = chip->irq; 2644 2645 #ifdef CONFIG_PM_SLEEP 2646 chip->suspend_mem = 2647 vmalloc(array_size(sizeof(u16), 2648 REV_B_CODE_MEMORY_LENGTH + 2649 REV_B_DATA_MEMORY_LENGTH)); 2650 if (chip->suspend_mem == NULL) 2651 dev_warn(card->dev, "can't allocate apm buffer\n"); 2765 2652 #endif 2766 2653 2767 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, 2768 card->driver, chip)) { 2769 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2770 snd_m3_free(chip); 2771 return -ENOMEM; 2772 } 2773 chip->irq = pci->irq; 2774 2775 #ifdef CONFIG_PM 2776 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); 2777 if (chip->suspend_mem == NULL) 2778 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2779 #endif 2780 2781 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2782 snd_m3_free(chip); 2783 return err; 2784 } 2654 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 2655 if (err < 0) 2656 goto free_chip; 2785 2657 2786 2658 if ((err = snd_m3_mixer(chip)) < 0) … … 2800 2672 err = snd_m3_input_register(chip); 2801 2673 if (err) 2802 snd_printk(KERN_WARNING "Input device registration " 2803 "failed with error %i", err); 2674 dev_warn(card->dev, 2675 "Input device registration failed with error %i", 2676 err); 2804 2677 } 2805 2678 #endif … … 2808 2681 snd_m3_assp_continue(chip); 2809 2682 2810 snd_card_set_dev(card, &pci->dev);2811 2812 2683 *chip_ret = chip; 2813 2684 2814 2685 return 0; 2686 2687 free_chip: 2688 snd_m3_free(chip); 2689 return err; 2815 2690 } 2816 2691 2817 2692 /* 2818 2693 */ 2819 static int __devinit2694 static int 2820 2695 snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 2821 2696 { … … 2825 2700 int err; 2826 2701 2827 #ifndef TARGET_OS22828 2702 /* don't pick up modems */ 2829 2703 if (((pci->class >> 8) & 0xffff) != PCI_CLASS_MULTIMEDIA_AUDIO) 2830 2704 return -ENODEV; 2831 #endif 2705 2832 2706 if (dev >= SNDRV_CARDS) 2833 2707 return -ENODEV; … … 2837 2711 } 2838 2712 2839 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2713 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2714 0, &card); 2840 2715 if (err < 0) 2841 2716 return err; … … 2855 2730 } 2856 2731 2857 if ((err = snd_m3_create(card, pci, 2858 external_amp[dev], 2859 amp_gpio[dev], 2860 &chip)) < 0) { 2861 snd_card_free(card); 2862 return err; 2863 } 2732 err = snd_m3_create(card, pci, external_amp[dev], amp_gpio[dev], &chip); 2733 if (err < 0) 2734 goto free_card; 2735 2864 2736 card->private_data = chip; 2865 2737 … … 2868 2740 card->shortname, chip->iobase, chip->irq); 2869 2741 2870 if ((err = snd_card_register(card)) < 0) { 2871 snd_card_free(card); 2872 return err; 2873 } 2742 err = snd_card_register(card); 2743 if (err < 0) 2744 goto free_card; 2874 2745 2875 2746 #if 0 /* TODO: not supported yet */ … … 2877 2748 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, 2878 2749 chip->iobase + MPU401_DATA_PORT, 2879 MPU401_INFO_INTEGRATED ,2880 chip->irq, 0, &chip->rmidi);2750 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, 2751 -1, &chip->rmidi); 2881 2752 if (err < 0) 2882 printk(KERN_WARNING "maestro3:no MIDI support.\n");2753 dev_warn(card->dev, "no MIDI support.\n"); 2883 2754 #endif 2884 2755 … … 2886 2757 dev++; 2887 2758 return 0; 2888 } 2889 2890 static void __devexit snd_m3_remove(struct pci_dev *pci) 2759 2760 free_card: 2761 snd_card_free(card); 2762 return err; 2763 } 2764 2765 static void snd_m3_remove(struct pci_dev *pci) 2891 2766 { 2892 2767 snd_card_free(pci_get_drvdata(pci)); 2893 pci_set_drvdata(pci, NULL); 2894 } 2895 2896 static struct pci_driver driver = { 2897 .name = "Maestro3", 2768 } 2769 2770 static struct pci_driver m3_driver = { 2771 .name = KBUILD_MODNAME, 2898 2772 .id_table = snd_m3_ids, 2899 2773 .probe = snd_m3_probe, 2900 .remove = __devexit_p(snd_m3_remove), 2901 #ifdef CONFIG_PM 2902 .suspend = m3_suspend, 2903 .resume = m3_resume, 2904 #endif 2774 .remove = snd_m3_remove, 2775 .driver = { 2776 .pm = M3_PM_OPS, 2777 }, 2905 2778 }; 2906 2779 2907 static int __init alsa_card_m3_init(void) 2908 { 2909 return pci_register_driver(&driver); 2910 } 2911 2912 static void __exit alsa_card_m3_exit(void) 2913 { 2914 pci_unregister_driver(&driver); 2915 } 2916 2917 module_init(alsa_card_m3_init) 2918 module_exit(alsa_card_m3_exit) 2780 module_pci_driver(m3_driver);
Note:
See TracChangeset
for help on using the changeset viewer.