diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-10-04 02:46:51 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-11-04 07:17:16 -0500 |
commit | b7fe46220487f684abc858865cff817389af5c76 (patch) | |
tree | d1eabbbdd0f686c87996133fd22ce2327da638c1 /sound/pci/via82xx.c | |
parent | 4b0940f8117b6cdf7e7c27bdecc29931f18c81ed (diff) |
[ALSA] highlanderize motherboard AC97/HDA drivers
Remove the code for supporting eight cards from the integrated
controller drivers because There Can Be Only One controller of
each type per mainboard.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/pci/via82xx.c')
-rw-r--r-- | sound/pci/via82xx.c | 103 |
1 files changed, 47 insertions, 56 deletions
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index ecc4836ba8de..4545208ee460 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -73,34 +73,31 @@ MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}"); | |||
73 | #define SUPPORT_JOYSTICK 1 | 73 | #define SUPPORT_JOYSTICK 1 |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 76 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ |
77 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 77 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ |
78 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | 78 | static long mpu_port; |
79 | static long mpu_port[SNDRV_CARDS]; | ||
80 | #ifdef SUPPORT_JOYSTICK | 79 | #ifdef SUPPORT_JOYSTICK |
81 | static int joystick[SNDRV_CARDS]; | 80 | static int joystick; |
82 | #endif | 81 | #endif |
83 | static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; | 82 | static int ac97_clock = 48000; |
84 | static char *ac97_quirk[SNDRV_CARDS]; | 83 | static char *ac97_quirk; |
85 | static int dxs_support[SNDRV_CARDS]; | 84 | static int dxs_support; |
86 | 85 | ||
87 | module_param_array(index, int, NULL, 0444); | 86 | module_param(index, int, 0444); |
88 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); | 87 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); |
89 | module_param_array(id, charp, NULL, 0444); | 88 | module_param(id, charp, 0444); |
90 | MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); | 89 | MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); |
91 | module_param_array(enable, bool, NULL, 0444); | 90 | module_param(mpu_port, long, 0444); |
92 | MODULE_PARM_DESC(enable, "Enable audio part of VIA 82xx bridge."); | ||
93 | module_param_array(mpu_port, long, NULL, 0444); | ||
94 | MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)"); | 91 | MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)"); |
95 | #ifdef SUPPORT_JOYSTICK | 92 | #ifdef SUPPORT_JOYSTICK |
96 | module_param_array(joystick, bool, NULL, 0444); | 93 | module_param(joystick, bool, 0444); |
97 | MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)"); | 94 | MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)"); |
98 | #endif | 95 | #endif |
99 | module_param_array(ac97_clock, int, NULL, 0444); | 96 | module_param(ac97_clock, int, 0444); |
100 | MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); | 97 | MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); |
101 | module_param_array(ac97_quirk, charp, NULL, 0444); | 98 | module_param(ac97_quirk, charp, 0444); |
102 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); | 99 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); |
103 | module_param_array(dxs_support, int, NULL, 0444); | 100 | module_param(dxs_support, int, 0444); |
104 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); | 101 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); |
105 | 102 | ||
106 | 103 | ||
@@ -1637,12 +1634,12 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_ov | |||
1637 | 1634 | ||
1638 | #ifdef SUPPORT_JOYSTICK | 1635 | #ifdef SUPPORT_JOYSTICK |
1639 | #define JOYSTICK_ADDR 0x200 | 1636 | #define JOYSTICK_ADDR 0x200 |
1640 | static int __devinit snd_via686_create_gameport(via82xx_t *chip, int dev, unsigned char *legacy) | 1637 | static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) |
1641 | { | 1638 | { |
1642 | struct gameport *gp; | 1639 | struct gameport *gp; |
1643 | struct resource *r; | 1640 | struct resource *r; |
1644 | 1641 | ||
1645 | if (!joystick[dev]) | 1642 | if (!joystick) |
1646 | return -ENODEV; | 1643 | return -ENODEV; |
1647 | 1644 | ||
1648 | r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); | 1645 | r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); |
@@ -1686,7 +1683,7 @@ static void snd_via686_free_gameport(via82xx_t *chip) | |||
1686 | } | 1683 | } |
1687 | } | 1684 | } |
1688 | #else | 1685 | #else |
1689 | static inline int snd_via686_create_gameport(via82xx_t *chip, int dev, unsigned char *legacy) | 1686 | static inline int snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) |
1690 | { | 1687 | { |
1691 | return -ENOSYS; | 1688 | return -ENOSYS; |
1692 | } | 1689 | } |
@@ -1698,7 +1695,7 @@ static inline void snd_via686_free_gameport(via82xx_t *chip) { } | |||
1698 | * | 1695 | * |
1699 | */ | 1696 | */ |
1700 | 1697 | ||
1701 | static int __devinit snd_via8233_init_misc(via82xx_t *chip, int dev) | 1698 | static int __devinit snd_via8233_init_misc(via82xx_t *chip) |
1702 | { | 1699 | { |
1703 | int i, err, caps; | 1700 | int i, err, caps; |
1704 | unsigned char val; | 1701 | unsigned char val; |
@@ -1739,7 +1736,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip, int dev) | |||
1739 | return 0; | 1736 | return 0; |
1740 | } | 1737 | } |
1741 | 1738 | ||
1742 | static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) | 1739 | static int __devinit snd_via686_init_misc(via82xx_t *chip) |
1743 | { | 1740 | { |
1744 | unsigned char legacy, legacy_cfg; | 1741 | unsigned char legacy, legacy_cfg; |
1745 | int rev_h = 0; | 1742 | int rev_h = 0; |
@@ -1750,32 +1747,33 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) | |||
1750 | legacy &= ~VIA_FUNC_ENABLE_GAME; /* disable joystick */ | 1747 | legacy &= ~VIA_FUNC_ENABLE_GAME; /* disable joystick */ |
1751 | if (chip->revision >= VIA_REV_686_H) { | 1748 | if (chip->revision >= VIA_REV_686_H) { |
1752 | rev_h = 1; | 1749 | rev_h = 1; |
1753 | if (mpu_port[dev] >= 0x200) { /* force MIDI */ | 1750 | if (mpu_port >= 0x200) { /* force MIDI */ |
1754 | mpu_port[dev] &= 0xfffc; | 1751 | mpu_port &= 0xfffc; |
1755 | pci_write_config_dword(chip->pci, 0x18, mpu_port[dev] | 0x01); | 1752 | pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); |
1756 | #ifdef CONFIG_PM | 1753 | #ifdef CONFIG_PM |
1757 | chip->mpu_port_saved = mpu_port[dev]; | 1754 | chip->mpu_port_saved = mpu_port; |
1758 | #endif | 1755 | #endif |
1759 | } else { | 1756 | } else { |
1760 | mpu_port[dev] = pci_resource_start(chip->pci, 2); | 1757 | mpu_port = pci_resource_start(chip->pci, 2); |
1761 | } | 1758 | } |
1762 | } else { | 1759 | } else { |
1763 | switch (mpu_port[dev]) { /* force MIDI */ | 1760 | switch (mpu_port) { /* force MIDI */ |
1764 | case 0x300: | 1761 | case 0x300: |
1765 | case 0x310: | 1762 | case 0x310: |
1766 | case 0x320: | 1763 | case 0x320: |
1767 | case 0x330: | 1764 | case 0x330: |
1768 | legacy_cfg &= ~(3 << 2); | 1765 | legacy_cfg &= ~(3 << 2); |
1769 | legacy_cfg |= (mpu_port[dev] & 0x0030) >> 2; | 1766 | legacy_cfg |= (mpu_port & 0x0030) >> 2; |
1770 | break; | 1767 | break; |
1771 | default: /* no, use BIOS settings */ | 1768 | default: /* no, use BIOS settings */ |
1772 | if (legacy & VIA_FUNC_ENABLE_MIDI) | 1769 | if (legacy & VIA_FUNC_ENABLE_MIDI) |
1773 | mpu_port[dev] = 0x300 + ((legacy_cfg & 0x000c) << 2); | 1770 | mpu_port = 0x300 + ((legacy_cfg & 0x000c) << 2); |
1774 | break; | 1771 | break; |
1775 | } | 1772 | } |
1776 | } | 1773 | } |
1777 | if (mpu_port[dev] >= 0x200 && | 1774 | if (mpu_port >= 0x200 && |
1778 | (chip->mpu_res = request_region(mpu_port[dev], 2, "VIA82xx MPU401")) != NULL) { | 1775 | (chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401")) |
1776 | != NULL) { | ||
1779 | if (rev_h) | 1777 | if (rev_h) |
1780 | legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */ | 1778 | legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */ |
1781 | legacy |= VIA_FUNC_ENABLE_MIDI; | 1779 | legacy |= VIA_FUNC_ENABLE_MIDI; |
@@ -1783,16 +1781,17 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) | |||
1783 | if (rev_h) | 1781 | if (rev_h) |
1784 | legacy &= ~VIA_FUNC_MIDI_PNP; /* disable PCI I/O 2 */ | 1782 | legacy &= ~VIA_FUNC_MIDI_PNP; /* disable PCI I/O 2 */ |
1785 | legacy &= ~VIA_FUNC_ENABLE_MIDI; | 1783 | legacy &= ~VIA_FUNC_ENABLE_MIDI; |
1786 | mpu_port[dev] = 0; | 1784 | mpu_port = 0; |
1787 | } | 1785 | } |
1788 | 1786 | ||
1789 | pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); | 1787 | pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); |
1790 | pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); | 1788 | pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); |
1791 | if (chip->mpu_res) { | 1789 | if (chip->mpu_res) { |
1792 | if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, | 1790 | if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, |
1793 | mpu_port[dev], 1, | 1791 | mpu_port, 1, |
1794 | chip->irq, 0, &chip->rmidi) < 0) { | 1792 | chip->irq, 0, &chip->rmidi) < 0) { |
1795 | printk(KERN_WARNING "unable to initialize MPU-401 at 0x%lx, skipping\n", mpu_port[dev]); | 1793 | printk(KERN_WARNING "unable to initialize MPU-401" |
1794 | " at 0x%lx, skipping\n", mpu_port); | ||
1796 | legacy &= ~VIA_FUNC_ENABLE_MIDI; | 1795 | legacy &= ~VIA_FUNC_ENABLE_MIDI; |
1797 | } else { | 1796 | } else { |
1798 | legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */ | 1797 | legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */ |
@@ -1800,7 +1799,7 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) | |||
1800 | pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); | 1799 | pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); |
1801 | } | 1800 | } |
1802 | 1801 | ||
1803 | snd_via686_create_gameport(chip, dev, &legacy); | 1802 | snd_via686_create_gameport(chip, &legacy); |
1804 | 1803 | ||
1805 | #ifdef CONFIG_PM | 1804 | #ifdef CONFIG_PM |
1806 | chip->legacy_saved = legacy; | 1805 | chip->legacy_saved = legacy; |
@@ -2221,7 +2220,6 @@ static int __devinit check_dxs_list(struct pci_dev *pci) | |||
2221 | static int __devinit snd_via82xx_probe(struct pci_dev *pci, | 2220 | static int __devinit snd_via82xx_probe(struct pci_dev *pci, |
2222 | const struct pci_device_id *pci_id) | 2221 | const struct pci_device_id *pci_id) |
2223 | { | 2222 | { |
2224 | static int dev; | ||
2225 | snd_card_t *card; | 2223 | snd_card_t *card; |
2226 | via82xx_t *chip; | 2224 | via82xx_t *chip; |
2227 | unsigned char revision; | 2225 | unsigned char revision; |
@@ -2229,14 +2227,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2229 | unsigned int i; | 2227 | unsigned int i; |
2230 | int err; | 2228 | int err; |
2231 | 2229 | ||
2232 | if (dev >= SNDRV_CARDS) | 2230 | card = snd_card_new(index, id, THIS_MODULE, 0); |
2233 | return -ENODEV; | ||
2234 | if (!enable[dev]) { | ||
2235 | dev++; | ||
2236 | return -ENOENT; | ||
2237 | } | ||
2238 | |||
2239 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | ||
2240 | if (card == NULL) | 2231 | if (card == NULL) |
2241 | return -ENOMEM; | 2232 | return -ENOMEM; |
2242 | 2233 | ||
@@ -2259,12 +2250,12 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2259 | } | 2250 | } |
2260 | } | 2251 | } |
2261 | if (chip_type != TYPE_VIA8233A) { | 2252 | if (chip_type != TYPE_VIA8233A) { |
2262 | if (dxs_support[dev] == VIA_DXS_AUTO) | 2253 | if (dxs_support == VIA_DXS_AUTO) |
2263 | dxs_support[dev] = check_dxs_list(pci); | 2254 | dxs_support = check_dxs_list(pci); |
2264 | /* force to use VIA8233 or 8233A model according to | 2255 | /* force to use VIA8233 or 8233A model according to |
2265 | * dxs_support module option | 2256 | * dxs_support module option |
2266 | */ | 2257 | */ |
2267 | if (dxs_support[dev] == VIA_DXS_DISABLE) | 2258 | if (dxs_support == VIA_DXS_DISABLE) |
2268 | chip_type = TYPE_VIA8233A; | 2259 | chip_type = TYPE_VIA8233A; |
2269 | else | 2260 | else |
2270 | chip_type = TYPE_VIA8233; | 2261 | chip_type = TYPE_VIA8233; |
@@ -2282,14 +2273,15 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2282 | goto __error; | 2273 | goto __error; |
2283 | } | 2274 | } |
2284 | 2275 | ||
2285 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0) | 2276 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, |
2277 | ac97_clock, &chip)) < 0) | ||
2286 | goto __error; | 2278 | goto __error; |
2287 | if ((err = snd_via82xx_mixer_new(chip, ac97_quirk[dev])) < 0) | 2279 | if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) |
2288 | goto __error; | 2280 | goto __error; |
2289 | 2281 | ||
2290 | if (chip_type == TYPE_VIA686) { | 2282 | if (chip_type == TYPE_VIA686) { |
2291 | if ((err = snd_via686_pcm_new(chip)) < 0 || | 2283 | if ((err = snd_via686_pcm_new(chip)) < 0 || |
2292 | (err = snd_via686_init_misc(chip, dev)) < 0) | 2284 | (err = snd_via686_init_misc(chip)) < 0) |
2293 | goto __error; | 2285 | goto __error; |
2294 | } else { | 2286 | } else { |
2295 | if (chip_type == TYPE_VIA8233A) { | 2287 | if (chip_type == TYPE_VIA8233A) { |
@@ -2299,16 +2291,16 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2299 | } else { | 2291 | } else { |
2300 | if ((err = snd_via8233_pcm_new(chip)) < 0) | 2292 | if ((err = snd_via8233_pcm_new(chip)) < 0) |
2301 | goto __error; | 2293 | goto __error; |
2302 | if (dxs_support[dev] == VIA_DXS_48K) | 2294 | if (dxs_support == VIA_DXS_48K) |
2303 | chip->dxs_fixed = 1; | 2295 | chip->dxs_fixed = 1; |
2304 | else if (dxs_support[dev] == VIA_DXS_NO_VRA) | 2296 | else if (dxs_support == VIA_DXS_NO_VRA) |
2305 | chip->no_vra = 1; | 2297 | chip->no_vra = 1; |
2306 | else if (dxs_support[dev] == VIA_DXS_SRC) { | 2298 | else if (dxs_support == VIA_DXS_SRC) { |
2307 | chip->no_vra = 1; | 2299 | chip->no_vra = 1; |
2308 | chip->dxs_src = 1; | 2300 | chip->dxs_src = 1; |
2309 | } | 2301 | } |
2310 | } | 2302 | } |
2311 | if ((err = snd_via8233_init_misc(chip, dev)) < 0) | 2303 | if ((err = snd_via8233_init_misc(chip)) < 0) |
2312 | goto __error; | 2304 | goto __error; |
2313 | } | 2305 | } |
2314 | 2306 | ||
@@ -2329,7 +2321,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2329 | return err; | 2321 | return err; |
2330 | } | 2322 | } |
2331 | pci_set_drvdata(pci, card); | 2323 | pci_set_drvdata(pci, card); |
2332 | dev++; | ||
2333 | return 0; | 2324 | return 0; |
2334 | 2325 | ||
2335 | __error: | 2326 | __error: |