11b8ff22fSClemens Ladisch /* 21b8ff22fSClemens Ladisch * C-Media CMI8788 driver for Asus Xonar cards 31b8ff22fSClemens Ladisch * 41b8ff22fSClemens Ladisch * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 51b8ff22fSClemens Ladisch * 61b8ff22fSClemens Ladisch * 71b8ff22fSClemens Ladisch * This driver is free software; you can redistribute it and/or modify 81b8ff22fSClemens Ladisch * it under the terms of the GNU General Public License, version 2. 91b8ff22fSClemens Ladisch * 101b8ff22fSClemens Ladisch * This driver is distributed in the hope that it will be useful, 111b8ff22fSClemens Ladisch * but WITHOUT ANY WARRANTY; without even the implied warranty of 121b8ff22fSClemens Ladisch * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 131b8ff22fSClemens Ladisch * GNU General Public License for more details. 141b8ff22fSClemens Ladisch * 151b8ff22fSClemens Ladisch * You should have received a copy of the GNU General Public License 161b8ff22fSClemens Ladisch * along with this driver; if not, write to the Free Software 171b8ff22fSClemens Ladisch * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 181b8ff22fSClemens Ladisch */ 191b8ff22fSClemens Ladisch 201b8ff22fSClemens Ladisch #include <linux/pci.h> 211b8ff22fSClemens Ladisch #include <linux/delay.h> 221b8ff22fSClemens Ladisch #include <sound/core.h> 231b8ff22fSClemens Ladisch #include <sound/initval.h> 241b8ff22fSClemens Ladisch #include <sound/pcm.h> 2565c3ac88SClemens Ladisch #include "xonar.h" 261b8ff22fSClemens Ladisch 271b8ff22fSClemens Ladisch MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 28a9d3cc48SClemens Ladisch MODULE_DESCRIPTION("Asus AVx00 driver"); 29d023dc0aSClemens Ladisch MODULE_LICENSE("GPL v2"); 30a9d3cc48SClemens Ladisch MODULE_SUPPORTED_DEVICE("{{Asus,AV100},{Asus,AV200}}"); 311b8ff22fSClemens Ladisch 321b8ff22fSClemens Ladisch static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 331b8ff22fSClemens Ladisch static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 341b8ff22fSClemens Ladisch static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 351b8ff22fSClemens Ladisch 361b8ff22fSClemens Ladisch module_param_array(index, int, NULL, 0444); 371b8ff22fSClemens Ladisch MODULE_PARM_DESC(index, "card index"); 381b8ff22fSClemens Ladisch module_param_array(id, charp, NULL, 0444); 391b8ff22fSClemens Ladisch MODULE_PARM_DESC(id, "ID string"); 401b8ff22fSClemens Ladisch module_param_array(enable, bool, NULL, 0444); 411b8ff22fSClemens Ladisch MODULE_PARM_DESC(enable, "enable card"); 421b8ff22fSClemens Ladisch 431b8ff22fSClemens Ladisch static struct pci_device_id xonar_ids[] __devinitdata = { 4465c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, 4565c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x8275) }, 4665c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, 4765c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x8314) }, 4865c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x8327) }, 4965c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, 5065c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, 5165c3ac88SClemens Ladisch { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, 5230459d7bSClemens Ladisch { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, 531b8ff22fSClemens Ladisch { } 541b8ff22fSClemens Ladisch }; 551b8ff22fSClemens Ladisch MODULE_DEVICE_TABLE(pci, xonar_ids); 561b8ff22fSClemens Ladisch 5730459d7bSClemens Ladisch static int __devinit get_xonar_model(struct oxygen *chip, 5830459d7bSClemens Ladisch const struct pci_device_id *id) 591b8ff22fSClemens Ladisch { 6065c3ac88SClemens Ladisch if (get_xonar_pcm179x_model(chip, id) >= 0) 6130459d7bSClemens Ladisch return 0; 6265c3ac88SClemens Ladisch if (get_xonar_cs43xx_model(chip, id) >= 0) 6365c3ac88SClemens Ladisch return 0; 6465c3ac88SClemens Ladisch return -EINVAL; 6530459d7bSClemens Ladisch } 6630459d7bSClemens Ladisch 6730459d7bSClemens Ladisch static int __devinit xonar_probe(struct pci_dev *pci, 6830459d7bSClemens Ladisch const struct pci_device_id *pci_id) 6930459d7bSClemens Ladisch { 701b8ff22fSClemens Ladisch static int dev; 711b8ff22fSClemens Ladisch int err; 721b8ff22fSClemens Ladisch 731b8ff22fSClemens Ladisch if (dev >= SNDRV_CARDS) 741b8ff22fSClemens Ladisch return -ENODEV; 751b8ff22fSClemens Ladisch if (!enable[dev]) { 761b8ff22fSClemens Ladisch ++dev; 771b8ff22fSClemens Ladisch return -ENOENT; 781b8ff22fSClemens Ladisch } 79bb718588SClemens Ladisch err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE, 8030459d7bSClemens Ladisch xonar_ids, get_xonar_model); 811b8ff22fSClemens Ladisch if (err >= 0) 821b8ff22fSClemens Ladisch ++dev; 831b8ff22fSClemens Ladisch return err; 841b8ff22fSClemens Ladisch } 851b8ff22fSClemens Ladisch 861b8ff22fSClemens Ladisch static struct pci_driver xonar_driver = { 871b8ff22fSClemens Ladisch .name = "AV200", 881b8ff22fSClemens Ladisch .id_table = xonar_ids, 891b8ff22fSClemens Ladisch .probe = xonar_probe, 901b8ff22fSClemens Ladisch .remove = __devexit_p(oxygen_pci_remove), 914a4bc53bSClemens Ladisch #ifdef CONFIG_PM 924a4bc53bSClemens Ladisch .suspend = oxygen_pci_suspend, 934a4bc53bSClemens Ladisch .resume = oxygen_pci_resume, 944a4bc53bSClemens Ladisch #endif 951b8ff22fSClemens Ladisch }; 961b8ff22fSClemens Ladisch 971b8ff22fSClemens Ladisch static int __init alsa_card_xonar_init(void) 981b8ff22fSClemens Ladisch { 991b8ff22fSClemens Ladisch return pci_register_driver(&xonar_driver); 1001b8ff22fSClemens Ladisch } 1011b8ff22fSClemens Ladisch 1021b8ff22fSClemens Ladisch static void __exit alsa_card_xonar_exit(void) 1031b8ff22fSClemens Ladisch { 1041b8ff22fSClemens Ladisch pci_unregister_driver(&xonar_driver); 1051b8ff22fSClemens Ladisch } 1061b8ff22fSClemens Ladisch 1071b8ff22fSClemens Ladisch module_init(alsa_card_xonar_init) 1081b8ff22fSClemens Ladisch module_exit(alsa_card_xonar_exit) 109