GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / sound / pci / ctxfi / xfi.c
blobf42e7e1a107457bf99091d5813b438a88fe31f2f
1 /*
2 * xfi linux driver.
4 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
6 * This source file is released under GPL v2 license (no other versions).
7 * See the COPYING file included in the main directory of this source
8 * distribution for the license terms and conditions.
9 */
11 #include <linux/init.h>
12 #include <linux/pci.h>
13 #include <linux/moduleparam.h>
14 #include <linux/pci_ids.h>
15 #include <sound/core.h>
16 #include <sound/initval.h>
17 #include "ctatc.h"
18 #include "cthardware.h"
20 MODULE_AUTHOR("Creative Technology Ltd");
21 MODULE_DESCRIPTION("X-Fi driver version 1.03");
22 MODULE_LICENSE("GPL v2");
23 MODULE_SUPPORTED_DEVICE("{{Creative Labs, Sound Blaster X-Fi}");
25 static unsigned int reference_rate = 48000;
26 static unsigned int multiple = 2;
27 MODULE_PARM_DESC(reference_rate, "Reference rate (default=48000)");
28 module_param(reference_rate, uint, S_IRUGO);
29 MODULE_PARM_DESC(multiple, "Rate multiplier (default=2)");
30 module_param(multiple, uint, S_IRUGO);
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 static unsigned int subsystem[SNDRV_CARDS];
37 module_param_array(index, int, NULL, 0444);
38 MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver");
39 module_param_array(id, charp, NULL, 0444);
40 MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver");
41 module_param_array(enable, bool, NULL, 0444);
42 MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver");
43 module_param_array(subsystem, int, NULL, 0444);
44 MODULE_PARM_DESC(subsystem, "Override subsystem ID for Creative X-Fi driver");
46 static DEFINE_PCI_DEVICE_TABLE(ct_pci_dev_ids) = {
47 /* only X-Fi is supported, so... */
48 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1),
49 .driver_data = ATC20K1,
51 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K2),
52 .driver_data = ATC20K2,
54 { 0, }
56 MODULE_DEVICE_TABLE(pci, ct_pci_dev_ids);
58 static int __devinit
59 ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
61 static int dev;
62 struct snd_card *card;
63 struct ct_atc *atc;
64 int err;
66 if (dev >= SNDRV_CARDS)
67 return -ENODEV;
69 if (!enable[dev]) {
70 dev++;
71 return -ENOENT;
73 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
74 if (err)
75 return err;
76 if ((reference_rate != 48000) && (reference_rate != 44100)) {
77 printk(KERN_ERR "ctxfi: Invalid reference_rate value %u!!!\n",
78 reference_rate);
79 printk(KERN_ERR "ctxfi: The valid values for reference_rate "
80 "are 48000 and 44100, Value 48000 is assumed.\n");
81 reference_rate = 48000;
83 if ((multiple != 1) && (multiple != 2)) {
84 printk(KERN_ERR "ctxfi: Invalid multiple value %u!!!\n",
85 multiple);
86 printk(KERN_ERR "ctxfi: The valid values for multiple are "
87 "1 and 2, Value 2 is assumed.\n");
88 multiple = 2;
90 err = ct_atc_create(card, pci, reference_rate, multiple,
91 pci_id->driver_data, subsystem[dev], &atc);
92 if (err < 0)
93 goto error;
95 card->private_data = atc;
97 /* Create alsa devices supported by this card */
98 err = ct_atc_create_alsa_devs(atc);
99 if (err < 0)
100 goto error;
102 strcpy(card->driver, "SB-XFi");
103 strcpy(card->shortname, "Creative X-Fi");
104 snprintf(card->longname, sizeof(card->longname), "%s %s %s",
105 card->shortname, atc->chip_name, atc->model_name);
107 err = snd_card_register(card);
108 if (err < 0)
109 goto error;
111 pci_set_drvdata(pci, card);
112 dev++;
114 return 0;
116 error:
117 snd_card_free(card);
118 return err;
121 static void __devexit ct_card_remove(struct pci_dev *pci)
123 snd_card_free(pci_get_drvdata(pci));
124 pci_set_drvdata(pci, NULL);
127 #ifdef CONFIG_PM
128 static int ct_card_suspend(struct pci_dev *pci, pm_message_t state)
130 struct snd_card *card = pci_get_drvdata(pci);
131 struct ct_atc *atc = card->private_data;
133 return atc->suspend(atc, state);
136 static int ct_card_resume(struct pci_dev *pci)
138 struct snd_card *card = pci_get_drvdata(pci);
139 struct ct_atc *atc = card->private_data;
141 return atc->resume(atc);
143 #endif
145 static struct pci_driver ct_driver = {
146 .name = "SB-XFi",
147 .id_table = ct_pci_dev_ids,
148 .probe = ct_card_probe,
149 .remove = __devexit_p(ct_card_remove),
150 #ifdef CONFIG_PM
151 .suspend = ct_card_suspend,
152 .resume = ct_card_resume,
153 #endif
156 static int __init ct_card_init(void)
158 return pci_register_driver(&ct_driver);
161 static void __exit ct_card_exit(void)
163 pci_unregister_driver(&ct_driver);
166 module_init(ct_card_init)
167 module_exit(ct_card_exit)