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.
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>
19 MODULE_AUTHOR("Creative Technology Ltd");
20 MODULE_DESCRIPTION("X-Fi driver version 1.03");
21 MODULE_LICENSE("GPLv2");
22 MODULE_SUPPORTED_DEVICE("{{Creative Labs, Sound Blaster X-Fi}");
24 static unsigned int reference_rate = 48000;
25 static unsigned int multiple = 2;
26 module_param(reference_rate, uint, S_IRUGO);
27 module_param(multiple, uint, S_IRUGO);
29 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
30 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
31 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
33 static struct pci_device_id ct_pci_dev_ids[] = {
34 /* only X-Fi is supported, so... */
35 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1) },
36 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K2) },
39 MODULE_DEVICE_TABLE(pci, ct_pci_dev_ids);
42 ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
45 struct snd_card *card;
49 if (dev >= SNDRV_CARDS)
56 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
59 if ((reference_rate != 48000) && (reference_rate != 44100)) {
60 printk(KERN_ERR "Invalid reference_rate value %u!!!\n"
61 "The valid values for reference_rate "
62 "are 48000 and 44100.\nValue 48000 is "
63 "assumed.\n", reference_rate);
64 reference_rate = 48000;
66 if ((multiple != 1) && (multiple != 2)) {
67 printk(KERN_ERR "Invalid multiple value %u!!!\nThe valid "
68 "values for multiple are 1 and 2.\nValue 2 "
69 "is assumed.\n", multiple);
72 err = ct_atc_create(card, pci, reference_rate, multiple, &atc);
76 card->private_data = atc;
78 /* Create alsa devices supported by this card */
79 err = atc->create_alsa_devs(atc);
83 strcpy(card->driver, "SB-XFi");
84 strcpy(card->shortname, "Creative X-Fi");
85 strcpy(card->longname, "Creative ALSA Driver X-Fi");
87 err = snd_card_register(card);
91 pci_set_drvdata(pci, card);
101 static void __devexit ct_card_remove(struct pci_dev *pci)
103 snd_card_free(pci_get_drvdata(pci));
104 pci_set_drvdata(pci, NULL);
107 static struct pci_driver ct_driver = {
109 .id_table = ct_pci_dev_ids,
110 .probe = ct_card_probe,
111 .remove = __devexit_p(ct_card_remove),
114 static int __init ct_card_init(void)
116 return pci_register_driver(&ct_driver);
119 static void __exit ct_card_exit(void)
121 pci_unregister_driver(&ct_driver);
124 module_init(ct_card_init)
125 module_exit(ct_card_exit)