xref: /openbmc/linux/sound/pci/oxygen/virtuoso.c (revision 5ae0095d)
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>
22da155d5bSPaul Gortmaker #include <linux/module.h>
231b8ff22fSClemens Ladisch #include <sound/core.h>
241b8ff22fSClemens Ladisch #include <sound/initval.h>
251b8ff22fSClemens Ladisch #include <sound/pcm.h>
2665c3ac88SClemens Ladisch #include "xonar.h"
271b8ff22fSClemens Ladisch 
281b8ff22fSClemens Ladisch MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
2945bc307fSClemens Ladisch MODULE_DESCRIPTION("Asus Virtuoso driver");
30d023dc0aSClemens Ladisch MODULE_LICENSE("GPL v2");
3145bc307fSClemens Ladisch MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
321b8ff22fSClemens Ladisch 
331b8ff22fSClemens Ladisch static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
341b8ff22fSClemens Ladisch static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
35a67ff6a5SRusty Russell static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
361b8ff22fSClemens Ladisch 
371b8ff22fSClemens Ladisch module_param_array(index, int, NULL, 0444);
381b8ff22fSClemens Ladisch MODULE_PARM_DESC(index, "card index");
391b8ff22fSClemens Ladisch module_param_array(id, charp, NULL, 0444);
401b8ff22fSClemens Ladisch MODULE_PARM_DESC(id, "ID string");
411b8ff22fSClemens Ladisch module_param_array(enable, bool, NULL, 0444);
421b8ff22fSClemens Ladisch MODULE_PARM_DESC(enable, "enable card");
431b8ff22fSClemens Ladisch 
449baa3c34SBenoit Taine static const struct pci_device_id xonar_ids[] = {
4565c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8269) },
4665c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8275) },
4765c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
4865c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8314) },
4965c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8327) },
5065c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x834f) },
5165c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835c) },
5265c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835d) },
532b830baeSClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835e) },
54d1db38c0SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x838e) },
555ae0095dSHarley Griggs 	{ OXYGEN_PCI_SUBID(0x1043, 0x8428) },
5644923632SSergiu Giurgiu 	{ OXYGEN_PCI_SUBID(0x1043, 0x8522) },
57f42bb222SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
5830459d7bSClemens Ladisch 	{ OXYGEN_PCI_SUBID_BROKEN_EEPROM },
591b8ff22fSClemens Ladisch 	{ }
601b8ff22fSClemens Ladisch };
611b8ff22fSClemens Ladisch MODULE_DEVICE_TABLE(pci, xonar_ids);
621b8ff22fSClemens Ladisch 
63f120a6fbSBill Pemberton static int get_xonar_model(struct oxygen *chip,
6430459d7bSClemens Ladisch 			   const struct pci_device_id *id)
651b8ff22fSClemens Ladisch {
6665c3ac88SClemens Ladisch 	if (get_xonar_pcm179x_model(chip, id) >= 0)
6730459d7bSClemens Ladisch 		return 0;
6865c3ac88SClemens Ladisch 	if (get_xonar_cs43xx_model(chip, id) >= 0)
6965c3ac88SClemens Ladisch 		return 0;
70d1db38c0SClemens Ladisch 	if (get_xonar_wm87x6_model(chip, id) >= 0)
71d1db38c0SClemens Ladisch 		return 0;
7265c3ac88SClemens Ladisch 	return -EINVAL;
7330459d7bSClemens Ladisch }
7430459d7bSClemens Ladisch 
75f120a6fbSBill Pemberton static int xonar_probe(struct pci_dev *pci,
7630459d7bSClemens Ladisch 		       const struct pci_device_id *pci_id)
7730459d7bSClemens Ladisch {
781b8ff22fSClemens Ladisch 	static int dev;
791b8ff22fSClemens Ladisch 	int err;
801b8ff22fSClemens Ladisch 
811b8ff22fSClemens Ladisch 	if (dev >= SNDRV_CARDS)
821b8ff22fSClemens Ladisch 		return -ENODEV;
831b8ff22fSClemens Ladisch 	if (!enable[dev]) {
841b8ff22fSClemens Ladisch 		++dev;
851b8ff22fSClemens Ladisch 		return -ENOENT;
861b8ff22fSClemens Ladisch 	}
87bb718588SClemens Ladisch 	err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
8830459d7bSClemens Ladisch 			       xonar_ids, get_xonar_model);
891b8ff22fSClemens Ladisch 	if (err >= 0)
901b8ff22fSClemens Ladisch 		++dev;
911b8ff22fSClemens Ladisch 	return err;
921b8ff22fSClemens Ladisch }
931b8ff22fSClemens Ladisch 
941b8ff22fSClemens Ladisch static struct pci_driver xonar_driver = {
953733e424STakashi Iwai 	.name = KBUILD_MODNAME,
961b8ff22fSClemens Ladisch 	.id_table = xonar_ids,
971b8ff22fSClemens Ladisch 	.probe = xonar_probe,
98f120a6fbSBill Pemberton 	.remove = oxygen_pci_remove,
99c7561cd8STakashi Iwai #ifdef CONFIG_PM_SLEEP
10068cb2b55STakashi Iwai 	.driver = {
10168cb2b55STakashi Iwai 		.pm = &oxygen_pci_pm,
10268cb2b55STakashi Iwai 	},
1034a4bc53bSClemens Ladisch #endif
1044c25b932SClemens Ladisch 	.shutdown = oxygen_pci_shutdown,
1051b8ff22fSClemens Ladisch };
1061b8ff22fSClemens Ladisch 
107e9f66d9bSTakashi Iwai module_pci_driver(xonar_driver);
108