xref: /openbmc/linux/sound/pci/oxygen/virtuoso.c (revision 9c9cf6be)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * C-Media CMI8788 driver for Asus Xonar cards
4  *
5  * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
6  */
7 
8 #include <linux/pci.h>
9 #include <linux/delay.h>
10 #include <linux/module.h>
11 #include <sound/core.h>
12 #include <sound/initval.h>
13 #include <sound/pcm.h>
14 #include "xonar.h"
15 
16 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
17 MODULE_DESCRIPTION("Asus Virtuoso driver");
18 MODULE_LICENSE("GPL v2");
19 MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
20 
21 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
22 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
23 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
24 
25 module_param_array(index, int, NULL, 0444);
26 MODULE_PARM_DESC(index, "card index");
27 module_param_array(id, charp, NULL, 0444);
28 MODULE_PARM_DESC(id, "ID string");
29 module_param_array(enable, bool, NULL, 0444);
30 MODULE_PARM_DESC(enable, "enable card");
31 
32 static const struct pci_device_id xonar_ids[] = {
33 	{ OXYGEN_PCI_SUBID(0x1043, 0x8269) },
34 	{ OXYGEN_PCI_SUBID(0x1043, 0x8275) },
35 	{ OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
36 	{ OXYGEN_PCI_SUBID(0x1043, 0x8314) },
37 	{ OXYGEN_PCI_SUBID(0x1043, 0x8327) },
38 	{ OXYGEN_PCI_SUBID(0x1043, 0x834f) },
39 	{ OXYGEN_PCI_SUBID(0x1043, 0x835c) },
40 	{ OXYGEN_PCI_SUBID(0x1043, 0x835d) },
41 	{ OXYGEN_PCI_SUBID(0x1043, 0x835e) },
42 	{ OXYGEN_PCI_SUBID(0x1043, 0x838e) },
43 	{ OXYGEN_PCI_SUBID(0x1043, 0x8428) },
44 	{ OXYGEN_PCI_SUBID(0x1043, 0x8522) },
45 	{ OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
46 	{ OXYGEN_PCI_SUBID_BROKEN_EEPROM },
47 	{ }
48 };
49 MODULE_DEVICE_TABLE(pci, xonar_ids);
50 
51 static int get_xonar_model(struct oxygen *chip,
52 			   const struct pci_device_id *id)
53 {
54 	if (get_xonar_pcm179x_model(chip, id) >= 0)
55 		return 0;
56 	if (get_xonar_cs43xx_model(chip, id) >= 0)
57 		return 0;
58 	if (get_xonar_wm87x6_model(chip, id) >= 0)
59 		return 0;
60 	return -EINVAL;
61 }
62 
63 static int xonar_probe(struct pci_dev *pci,
64 		       const struct pci_device_id *pci_id)
65 {
66 	static int dev;
67 	int err;
68 
69 	if (dev >= SNDRV_CARDS)
70 		return -ENODEV;
71 	if (!enable[dev]) {
72 		++dev;
73 		return -ENOENT;
74 	}
75 	err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
76 			       xonar_ids, get_xonar_model);
77 	if (err >= 0)
78 		++dev;
79 	return err;
80 }
81 
82 static struct pci_driver xonar_driver = {
83 	.name = KBUILD_MODNAME,
84 	.id_table = xonar_ids,
85 	.probe = xonar_probe,
86 	.remove = oxygen_pci_remove,
87 #ifdef CONFIG_PM_SLEEP
88 	.driver = {
89 		.pm = &oxygen_pci_pm,
90 	},
91 #endif
92 	.shutdown = oxygen_pci_shutdown,
93 };
94 
95 module_pci_driver(xonar_driver);
96