xref: /openbmc/linux/sound/pci/oxygen/virtuoso.c (revision 596ae97a)
19c9cf6beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
21b8ff22fSClemens Ladisch /*
31b8ff22fSClemens Ladisch  * C-Media CMI8788 driver for Asus Xonar cards
41b8ff22fSClemens Ladisch  *
51b8ff22fSClemens Ladisch  * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
61b8ff22fSClemens Ladisch  */
71b8ff22fSClemens Ladisch 
81b8ff22fSClemens Ladisch #include <linux/pci.h>
91b8ff22fSClemens Ladisch #include <linux/delay.h>
10da155d5bSPaul Gortmaker #include <linux/module.h>
111b8ff22fSClemens Ladisch #include <sound/core.h>
121b8ff22fSClemens Ladisch #include <sound/initval.h>
131b8ff22fSClemens Ladisch #include <sound/pcm.h>
1465c3ac88SClemens Ladisch #include "xonar.h"
151b8ff22fSClemens Ladisch 
161b8ff22fSClemens Ladisch MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
1745bc307fSClemens Ladisch MODULE_DESCRIPTION("Asus Virtuoso driver");
18d023dc0aSClemens Ladisch MODULE_LICENSE("GPL v2");
191b8ff22fSClemens Ladisch 
201b8ff22fSClemens Ladisch static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
211b8ff22fSClemens Ladisch static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
22a67ff6a5SRusty Russell static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
231b8ff22fSClemens Ladisch 
241b8ff22fSClemens Ladisch module_param_array(index, int, NULL, 0444);
251b8ff22fSClemens Ladisch MODULE_PARM_DESC(index, "card index");
261b8ff22fSClemens Ladisch module_param_array(id, charp, NULL, 0444);
271b8ff22fSClemens Ladisch MODULE_PARM_DESC(id, "ID string");
281b8ff22fSClemens Ladisch module_param_array(enable, bool, NULL, 0444);
291b8ff22fSClemens Ladisch MODULE_PARM_DESC(enable, "enable card");
301b8ff22fSClemens Ladisch 
319baa3c34SBenoit Taine static const struct pci_device_id xonar_ids[] = {
3265c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8269) },
3365c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8275) },
3465c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
3565c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8314) },
3665c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x8327) },
3765c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x834f) },
3865c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835c) },
3965c3ac88SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835d) },
402b830baeSClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x835e) },
41d1db38c0SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x838e) },
425ae0095dSHarley Griggs 	{ OXYGEN_PCI_SUBID(0x1043, 0x8428) },
4344923632SSergiu Giurgiu 	{ OXYGEN_PCI_SUBID(0x1043, 0x8522) },
44f42bb222SClemens Ladisch 	{ OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
4530459d7bSClemens Ladisch 	{ OXYGEN_PCI_SUBID_BROKEN_EEPROM },
461b8ff22fSClemens Ladisch 	{ }
471b8ff22fSClemens Ladisch };
481b8ff22fSClemens Ladisch MODULE_DEVICE_TABLE(pci, xonar_ids);
491b8ff22fSClemens Ladisch 
get_xonar_model(struct oxygen * chip,const struct pci_device_id * id)50f120a6fbSBill Pemberton static int get_xonar_model(struct oxygen *chip,
5130459d7bSClemens Ladisch 			   const struct pci_device_id *id)
521b8ff22fSClemens Ladisch {
5365c3ac88SClemens Ladisch 	if (get_xonar_pcm179x_model(chip, id) >= 0)
5430459d7bSClemens Ladisch 		return 0;
5565c3ac88SClemens Ladisch 	if (get_xonar_cs43xx_model(chip, id) >= 0)
5665c3ac88SClemens Ladisch 		return 0;
57d1db38c0SClemens Ladisch 	if (get_xonar_wm87x6_model(chip, id) >= 0)
58d1db38c0SClemens Ladisch 		return 0;
5965c3ac88SClemens Ladisch 	return -EINVAL;
6030459d7bSClemens Ladisch }
6130459d7bSClemens Ladisch 
xonar_probe(struct pci_dev * pci,const struct pci_device_id * pci_id)62f120a6fbSBill Pemberton static int xonar_probe(struct pci_dev *pci,
6330459d7bSClemens Ladisch 		       const struct pci_device_id *pci_id)
6430459d7bSClemens Ladisch {
651b8ff22fSClemens Ladisch 	static int dev;
661b8ff22fSClemens Ladisch 	int err;
671b8ff22fSClemens Ladisch 
681b8ff22fSClemens Ladisch 	if (dev >= SNDRV_CARDS)
691b8ff22fSClemens Ladisch 		return -ENODEV;
701b8ff22fSClemens Ladisch 	if (!enable[dev]) {
711b8ff22fSClemens Ladisch 		++dev;
721b8ff22fSClemens Ladisch 		return -ENOENT;
731b8ff22fSClemens Ladisch 	}
74bb718588SClemens Ladisch 	err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
7530459d7bSClemens Ladisch 			       xonar_ids, get_xonar_model);
761b8ff22fSClemens Ladisch 	if (err >= 0)
771b8ff22fSClemens Ladisch 		++dev;
781b8ff22fSClemens Ladisch 	return err;
791b8ff22fSClemens Ladisch }
801b8ff22fSClemens Ladisch 
811b8ff22fSClemens Ladisch static struct pci_driver xonar_driver = {
823733e424STakashi Iwai 	.name = KBUILD_MODNAME,
831b8ff22fSClemens Ladisch 	.id_table = xonar_ids,
841b8ff22fSClemens Ladisch 	.probe = xonar_probe,
85c7561cd8STakashi Iwai #ifdef CONFIG_PM_SLEEP
8668cb2b55STakashi Iwai 	.driver = {
8768cb2b55STakashi Iwai 		.pm = &oxygen_pci_pm,
8868cb2b55STakashi Iwai 	},
894a4bc53bSClemens Ladisch #endif
904c25b932SClemens Ladisch 	.shutdown = oxygen_pci_shutdown,
911b8ff22fSClemens Ladisch };
921b8ff22fSClemens Ladisch 
93e9f66d9bSTakashi Iwai module_pci_driver(xonar_driver);
94