blob: f03a2f2cffee88911e9c11db08c5dd7dd8087b55 [file] [log] [blame]
Clemens Ladisch1b8ff222007-12-23 19:52:08 +01001/*
2 * C-Media CMI8788 driver for Asus Xonar cards
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.
9 *
10 * This driver is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010020#include <linux/pci.h>
21#include <linux/delay.h>
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010022#include <sound/core.h>
23#include <sound/initval.h>
24#include <sound/pcm.h>
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020025#include "xonar.h"
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010026
27MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
Clemens Ladischa9d3cc42008-04-07 10:29:44 +020028MODULE_DESCRIPTION("Asus AVx00 driver");
Clemens Ladischd023dc02008-05-13 09:18:27 +020029MODULE_LICENSE("GPL v2");
Clemens Ladischa9d3cc42008-04-07 10:29:44 +020030MODULE_SUPPORTED_DEVICE("{{Asus,AV100},{Asus,AV200}}");
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010031
32static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
33static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
34static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
35
36module_param_array(index, int, NULL, 0444);
37MODULE_PARM_DESC(index, "card index");
38module_param_array(id, charp, NULL, 0444);
39MODULE_PARM_DESC(id, "ID string");
40module_param_array(enable, bool, NULL, 0444);
41MODULE_PARM_DESC(enable, "enable card");
42
Alexey Dobriyancebe41d2010-02-06 00:21:03 +020043static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = {
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020044 { OXYGEN_PCI_SUBID(0x1043, 0x8269) },
45 { OXYGEN_PCI_SUBID(0x1043, 0x8275) },
46 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
47 { OXYGEN_PCI_SUBID(0x1043, 0x8314) },
48 { OXYGEN_PCI_SUBID(0x1043, 0x8327) },
49 { OXYGEN_PCI_SUBID(0x1043, 0x834f) },
50 { OXYGEN_PCI_SUBID(0x1043, 0x835c) },
51 { OXYGEN_PCI_SUBID(0x1043, 0x835d) },
Clemens Ladischd1db38c2010-01-18 15:44:04 +010052 { OXYGEN_PCI_SUBID(0x1043, 0x838e) },
Clemens Ladisch30459d72009-02-19 08:42:44 +010053 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010054 { }
55};
56MODULE_DEVICE_TABLE(pci, xonar_ids);
57
Clemens Ladisch30459d72009-02-19 08:42:44 +010058static int __devinit get_xonar_model(struct oxygen *chip,
59 const struct pci_device_id *id)
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010060{
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020061 if (get_xonar_pcm179x_model(chip, id) >= 0)
62 return 0;
63 if (get_xonar_cs43xx_model(chip, id) >= 0)
64 return 0;
Clemens Ladischd1db38c2010-01-18 15:44:04 +010065 if (get_xonar_wm87x6_model(chip, id) >= 0)
66 return 0;
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020067 return -EINVAL;
Clemens Ladisch30459d72009-02-19 08:42:44 +010068}
69
70static int __devinit xonar_probe(struct pci_dev *pci,
71 const struct pci_device_id *pci_id)
72{
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010073 static int dev;
74 int err;
75
76 if (dev >= SNDRV_CARDS)
77 return -ENODEV;
78 if (!enable[dev]) {
79 ++dev;
80 return -ENOENT;
81 }
Clemens Ladischbb718582009-02-19 08:37:13 +010082 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
Clemens Ladisch30459d72009-02-19 08:42:44 +010083 xonar_ids, get_xonar_model);
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010084 if (err >= 0)
85 ++dev;
86 return err;
87}
88
89static struct pci_driver xonar_driver = {
90 .name = "AV200",
91 .id_table = xonar_ids,
92 .probe = xonar_probe,
93 .remove = __devexit_p(oxygen_pci_remove),
Clemens Ladisch4a4bc532008-05-13 09:24:39 +020094#ifdef CONFIG_PM
95 .suspend = oxygen_pci_suspend,
96 .resume = oxygen_pci_resume,
97#endif
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010098};
99
100static int __init alsa_card_xonar_init(void)
101{
102 return pci_register_driver(&xonar_driver);
103}
104
105static void __exit alsa_card_xonar_exit(void)
106{
107 pci_unregister_driver(&xonar_driver);
108}
109
110module_init(alsa_card_xonar_init)
111module_exit(alsa_card_xonar_exit)