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> |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 22 | #include <sound/core.h> |
| 23 | #include <sound/initval.h> |
| 24 | #include <sound/pcm.h> |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 25 | #include "xonar.h" |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 26 | |
| 27 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
Clemens Ladisch | 45bc307 | 2010-10-04 13:17:26 +0200 | [diff] [blame] | 28 | MODULE_DESCRIPTION("Asus Virtuoso driver"); |
Clemens Ladisch | d023dc0 | 2008-05-13 09:18:27 +0200 | [diff] [blame] | 29 | MODULE_LICENSE("GPL v2"); |
Clemens Ladisch | 45bc307 | 2010-10-04 13:17:26 +0200 | [diff] [blame] | 30 | MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}"); |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 31 | |
| 32 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
| 33 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
| 34 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
| 35 | |
| 36 | module_param_array(index, int, NULL, 0444); |
| 37 | MODULE_PARM_DESC(index, "card index"); |
| 38 | module_param_array(id, charp, NULL, 0444); |
| 39 | MODULE_PARM_DESC(id, "ID string"); |
| 40 | module_param_array(enable, bool, NULL, 0444); |
| 41 | MODULE_PARM_DESC(enable, "enable card"); |
| 42 | |
Alexey Dobriyan | cebe41d | 2010-02-06 00:21:03 +0200 | [diff] [blame] | 43 | static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = { |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 44 | { 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 Ladisch | 2b830ba | 2010-10-04 13:22:51 +0200 | [diff] [blame] | 52 | { OXYGEN_PCI_SUBID(0x1043, 0x835e) }, |
Clemens Ladisch | d1db38c | 2010-01-18 15:44:04 +0100 | [diff] [blame] | 53 | { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 54 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 55 | { } |
| 56 | }; |
| 57 | MODULE_DEVICE_TABLE(pci, xonar_ids); |
| 58 | |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 59 | static int __devinit get_xonar_model(struct oxygen *chip, |
| 60 | const struct pci_device_id *id) |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 61 | { |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 62 | if (get_xonar_pcm179x_model(chip, id) >= 0) |
| 63 | return 0; |
| 64 | if (get_xonar_cs43xx_model(chip, id) >= 0) |
| 65 | return 0; |
Clemens Ladisch | d1db38c | 2010-01-18 15:44:04 +0100 | [diff] [blame] | 66 | if (get_xonar_wm87x6_model(chip, id) >= 0) |
| 67 | return 0; |
Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame] | 68 | return -EINVAL; |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | static int __devinit xonar_probe(struct pci_dev *pci, |
| 72 | const struct pci_device_id *pci_id) |
| 73 | { |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 74 | static int dev; |
| 75 | int err; |
| 76 | |
| 77 | if (dev >= SNDRV_CARDS) |
| 78 | return -ENODEV; |
| 79 | if (!enable[dev]) { |
| 80 | ++dev; |
| 81 | return -ENOENT; |
| 82 | } |
Clemens Ladisch | bb71858 | 2009-02-19 08:37:13 +0100 | [diff] [blame] | 83 | err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE, |
Clemens Ladisch | 30459d7 | 2009-02-19 08:42:44 +0100 | [diff] [blame] | 84 | xonar_ids, get_xonar_model); |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 85 | if (err >= 0) |
| 86 | ++dev; |
| 87 | return err; |
| 88 | } |
| 89 | |
| 90 | static struct pci_driver xonar_driver = { |
| 91 | .name = "AV200", |
| 92 | .id_table = xonar_ids, |
| 93 | .probe = xonar_probe, |
| 94 | .remove = __devexit_p(oxygen_pci_remove), |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 95 | #ifdef CONFIG_PM |
| 96 | .suspend = oxygen_pci_suspend, |
| 97 | .resume = oxygen_pci_resume, |
| 98 | #endif |
Clemens Ladisch | 4c25b93 | 2010-09-07 13:37:10 +0200 | [diff] [blame] | 99 | .shutdown = oxygen_pci_shutdown, |
Clemens Ladisch | 1b8ff22 | 2007-12-23 19:52:08 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | static int __init alsa_card_xonar_init(void) |
| 103 | { |
| 104 | return pci_register_driver(&xonar_driver); |
| 105 | } |
| 106 | |
| 107 | static void __exit alsa_card_xonar_exit(void) |
| 108 | { |
| 109 | pci_unregister_driver(&xonar_driver); |
| 110 | } |
| 111 | |
| 112 | module_init(alsa_card_xonar_init) |
| 113 | module_exit(alsa_card_xonar_exit) |