Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 1 | /* |
| 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 Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 20 | #include <linux/pci.h> |
| 21 | #include <linux/delay.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 22 | #include <linux/module.h> |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 23 | #include <sound/core.h> |
| 24 | #include <sound/initval.h> |
| 25 | #include <sound/pcm.h> |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 26 | #include "xonar.h" |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 27 | |
| 28 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
Clemens Ladisch | 45bc307 | 2010-10-04 13:17:26 +0200 | [diff] [blame] | 29 | MODULE_DESCRIPTION("Asus Virtuoso driver"); |
Clemens Ladisch | d023dc0 | 2008-05-13 09:18:27 +0200 | [diff] [blame] | 30 | MODULE_LICENSE("GPL v2"); |
Clemens Ladisch | 45bc307 | 2010-10-04 13:17:26 +0200 | [diff] [blame] | 31 | MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}"); |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 32 | |
| 33 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
| 34 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
Rusty Russell | a67ff6a | 2011-12-15 13:49:36 +1030 | [diff] [blame] | 35 | static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 36 | |
| 37 | module_param_array(index, int, NULL, 0444); |
| 38 | MODULE_PARM_DESC(index, "card index"); |
| 39 | module_param_array(id, charp, NULL, 0444); |
| 40 | MODULE_PARM_DESC(id, "ID string"); |
| 41 | module_param_array(enable, bool, NULL, 0444); |
| 42 | MODULE_PARM_DESC(enable, "enable card"); |
| 43 | |
Benoit Taine | 9baa3c3 | 2014-08-08 15:56:03 +0200 | [diff] [blame] | 44 | static const struct pci_device_id xonar_ids[] = { |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 45 | { 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 Ladisch | 2b830ba | 2010-10-04 13:22:51 +0200 | [diff] [blame] | 53 | { OXYGEN_PCI_SUBID(0x1043, 0x835e) }, |
Clemens Ladisch | d1db38c | 2010-01-18 15:44:04 +0100 | [diff] [blame] | 54 | { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, |
Harley Griggs | 5ae0095 | 2014-09-10 19:58:25 +0100 | [diff] [blame] | 55 | { OXYGEN_PCI_SUBID(0x1043, 0x8428) }, |
Sergiu Giurgiu | 4492363 | 2012-09-09 05:14:15 -0400 | [diff] [blame] | 56 | { OXYGEN_PCI_SUBID(0x1043, 0x8522) }, |
Clemens Ladisch | f42bb22 | 2014-08-04 15:17:55 +0200 | [diff] [blame] | 57 | { OXYGEN_PCI_SUBID(0x1043, 0x85f4) }, |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 58 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 59 | { } |
| 60 | }; |
| 61 | MODULE_DEVICE_TABLE(pci, xonar_ids); |
| 62 | |
Bill Pemberton | f120a6f | 2012-12-06 12:35:20 -0500 | [diff] [blame] | 63 | static int get_xonar_model(struct oxygen *chip, |
| 64 | const struct pci_device_id *id) |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 65 | { |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 66 | if (get_xonar_pcm179x_model(chip, id) >= 0) |
| 67 | return 0; |
| 68 | if (get_xonar_cs43xx_model(chip, id) >= 0) |
| 69 | return 0; |
Clemens Ladisch | d1db38c | 2010-01-18 15:44:04 +0100 | [diff] [blame] | 70 | if (get_xonar_wm87x6_model(chip, id) >= 0) |
| 71 | return 0; |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 72 | return -EINVAL; |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Bill Pemberton | f120a6f | 2012-12-06 12:35:20 -0500 | [diff] [blame] | 75 | static int xonar_probe(struct pci_dev *pci, |
| 76 | const struct pci_device_id *pci_id) |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 77 | { |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 78 | 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 Ladisch | bb71858 | 2009-02-19 08:37:13 +0100 | [diff] [blame] | 87 | err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE, |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 88 | xonar_ids, get_xonar_model); |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 89 | if (err >= 0) |
| 90 | ++dev; |
| 91 | return err; |
| 92 | } |
| 93 | |
| 94 | static struct pci_driver xonar_driver = { |
Takashi Iwai | 3733e42 | 2011-06-10 16:20:20 +0200 | [diff] [blame] | 95 | .name = KBUILD_MODNAME, |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 96 | .id_table = xonar_ids, |
| 97 | .probe = xonar_probe, |
Bill Pemberton | f120a6f | 2012-12-06 12:35:20 -0500 | [diff] [blame] | 98 | .remove = oxygen_pci_remove, |
Takashi Iwai | c7561cd | 2012-08-14 18:12:04 +0200 | [diff] [blame] | 99 | #ifdef CONFIG_PM_SLEEP |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 100 | .driver = { |
| 101 | .pm = &oxygen_pci_pm, |
| 102 | }, |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 103 | #endif |
Clemens Ladisch | 4c25b93 | 2010-09-07 13:37:10 +0200 | [diff] [blame] | 104 | .shutdown = oxygen_pci_shutdown, |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
Takashi Iwai | e9f66d9 | 2012-04-24 12:25:00 +0200 | [diff] [blame] | 107 | module_pci_driver(xonar_driver); |