blob: 83de6fb01021e6053f15b9e2ad5cdb15bddcb88c [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>
Paul Gortmakerda155d52011-07-15 12:38:28 -040022#include <linux/module.h>
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010023#include <sound/core.h>
24#include <sound/initval.h>
25#include <sound/pcm.h>
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020026#include "xonar.h"
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010027
28MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
Clemens Ladisch45bc3072010-10-04 13:17:26 +020029MODULE_DESCRIPTION("Asus Virtuoso driver");
Clemens Ladischd023dc02008-05-13 09:18:27 +020030MODULE_LICENSE("GPL v2");
Clemens Ladisch45bc3072010-10-04 13:17:26 +020031MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010032
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
Rusty Russella67ff6a2011-12-15 13:49:36 +103035static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010036
37module_param_array(index, int, NULL, 0444);
38MODULE_PARM_DESC(index, "card index");
39module_param_array(id, charp, NULL, 0444);
40MODULE_PARM_DESC(id, "ID string");
41module_param_array(enable, bool, NULL, 0444);
42MODULE_PARM_DESC(enable, "enable card");
43
Benoit Taine9baa3c32014-08-08 15:56:03 +020044static const struct pci_device_id xonar_ids[] = {
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020045 { OXYGEN_PCI_SUBID(0x1043, 0x8269) },
46 { OXYGEN_PCI_SUBID(0x1043, 0x8275) },
47 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
48 { OXYGEN_PCI_SUBID(0x1043, 0x8314) },
49 { OXYGEN_PCI_SUBID(0x1043, 0x8327) },
50 { OXYGEN_PCI_SUBID(0x1043, 0x834f) },
51 { OXYGEN_PCI_SUBID(0x1043, 0x835c) },
52 { OXYGEN_PCI_SUBID(0x1043, 0x835d) },
Clemens Ladisch2b830ba2010-10-04 13:22:51 +020053 { OXYGEN_PCI_SUBID(0x1043, 0x835e) },
Clemens Ladischd1db38c2010-01-18 15:44:04 +010054 { OXYGEN_PCI_SUBID(0x1043, 0x838e) },
Harley Griggs5ae00952014-09-10 19:58:25 +010055 { OXYGEN_PCI_SUBID(0x1043, 0x8428) },
Sergiu Giurgiu44923632012-09-09 05:14:15 -040056 { OXYGEN_PCI_SUBID(0x1043, 0x8522) },
Clemens Ladischf42bb222014-08-04 15:17:55 +020057 { OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
Clemens Ladisch30459d72009-02-19 08:42:44 +010058 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010059 { }
60};
61MODULE_DEVICE_TABLE(pci, xonar_ids);
62
Bill Pembertonf120a6f2012-12-06 12:35:20 -050063static int get_xonar_model(struct oxygen *chip,
64 const struct pci_device_id *id)
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010065{
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020066 if (get_xonar_pcm179x_model(chip, id) >= 0)
67 return 0;
68 if (get_xonar_cs43xx_model(chip, id) >= 0)
69 return 0;
Clemens Ladischd1db38c2010-01-18 15:44:04 +010070 if (get_xonar_wm87x6_model(chip, id) >= 0)
71 return 0;
Clemens Ladisch65c3ac82009-09-28 11:11:27 +020072 return -EINVAL;
Clemens Ladisch30459d72009-02-19 08:42:44 +010073}
74
Bill Pembertonf120a6f2012-12-06 12:35:20 -050075static int xonar_probe(struct pci_dev *pci,
76 const struct pci_device_id *pci_id)
Clemens Ladisch30459d72009-02-19 08:42:44 +010077{
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010078 static int dev;
79 int err;
80
81 if (dev >= SNDRV_CARDS)
82 return -ENODEV;
83 if (!enable[dev]) {
84 ++dev;
85 return -ENOENT;
86 }
Clemens Ladischbb718582009-02-19 08:37:13 +010087 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
Clemens Ladisch30459d72009-02-19 08:42:44 +010088 xonar_ids, get_xonar_model);
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010089 if (err >= 0)
90 ++dev;
91 return err;
92}
93
94static struct pci_driver xonar_driver = {
Takashi Iwai3733e422011-06-10 16:20:20 +020095 .name = KBUILD_MODNAME,
Clemens Ladisch1b8ff222007-12-23 19:52:08 +010096 .id_table = xonar_ids,
97 .probe = xonar_probe,
Bill Pembertonf120a6f2012-12-06 12:35:20 -050098 .remove = oxygen_pci_remove,
Takashi Iwaic7561cd2012-08-14 18:12:04 +020099#ifdef CONFIG_PM_SLEEP
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200100 .driver = {
101 .pm = &oxygen_pci_pm,
102 },
Clemens Ladisch4a4bc532008-05-13 09:24:39 +0200103#endif
Clemens Ladisch4c25b932010-09-07 13:37:10 +0200104 .shutdown = oxygen_pci_shutdown,
Clemens Ladisch1b8ff222007-12-23 19:52:08 +0100105};
106
Takashi Iwaie9f66d92012-04-24 12:25:00 +0200107module_pci_driver(xonar_driver);