1 | /*
|
---|
2 | * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
|
---|
3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*
|
---|
23 | NOTES:
|
---|
24 | - sometimes the sound is metallic and sibilant, unloading and
|
---|
25 | reloading the module may solve this.
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include <sound/driver.h>
|
---|
29 | #include <linux/pci.h>
|
---|
30 | #include <linux/time.h>
|
---|
31 | #include <linux/init.h>
|
---|
32 | #include <sound/core.h>
|
---|
33 | #include <sound/cs46xx.h>
|
---|
34 | #define SNDRV_GET_ID
|
---|
35 | #include <sound/initval.h>
|
---|
36 |
|
---|
37 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
|
---|
38 | MODULE_DESCRIPTION("Cirrus Logic Sound Fusion CS46XX");
|
---|
39 | MODULE_LICENSE("GPL");
|
---|
40 | MODULE_CLASSES("{sound}");
|
---|
41 | MODULE_DEVICES("{{Cirrus Logic,Sound Fusion (CS4280)},"
|
---|
42 | "{Cirrus Logic,Sound Fusion (CS4610)},"
|
---|
43 | "{Cirrus Logic,Sound Fusion (CS4612)},"
|
---|
44 | "{Cirrus Logic,Sound Fusion (CS4615)},"
|
---|
45 | "{Cirrus Logic,Sound Fusion (CS4622)},"
|
---|
46 | "{Cirrus Logic,Sound Fusion (CS4624)},"
|
---|
47 | "{Cirrus Logic,Sound Fusion (CS4630)}}");
|
---|
48 |
|
---|
49 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
---|
50 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
---|
51 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
|
---|
52 | #ifdef TARGET_OS2
|
---|
53 | static int external_amp[SNDRV_CARDS] = {0};
|
---|
54 | static int thinkpad[SNDRV_CARDS] = {1,0,0,0,0,0,0,0};
|
---|
55 | static int mmap_valid[SNDRV_CARDS] = {0};
|
---|
56 | #else
|
---|
57 | static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
58 | static int thinkpad[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
59 | static int mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
63 | MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard.");
|
---|
64 | MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
|
---|
65 | MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
|
---|
66 | MODULE_PARM_DESC(id, "ID string for the CS46xx soundcard.");
|
---|
67 | MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
|
---|
68 | MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
69 | MODULE_PARM_DESC(enable, "Enable CS46xx soundcard.");
|
---|
70 | MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
|
---|
71 | MODULE_PARM(external_amp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
72 | MODULE_PARM_DESC(external_amp, "Force to enable external amplifer.");
|
---|
73 | MODULE_PARM_SYNTAX(external_amp, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
|
---|
74 | MODULE_PARM(thinkpad, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
75 | MODULE_PARM_DESC(thinkpad, "Force to enable Thinkpad's CLKRUN control.");
|
---|
76 | MODULE_PARM_SYNTAX(thinkpad, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
|
---|
77 | MODULE_PARM(mmap_valid, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
78 | MODULE_PARM_DESC(mmap_valid, "Support OSS mmap.");
|
---|
79 | MODULE_PARM_SYNTAX(mmap_valid, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
|
---|
80 |
|
---|
81 | static struct pci_device_id snd_cs46xx_ids[] = {
|
---|
82 | { 0x1013, 0x6001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4280 */
|
---|
83 | { 0x1013, 0x6003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4612 */
|
---|
84 | { 0x1013, 0x6004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4615 */
|
---|
85 | { 0, }
|
---|
86 | };
|
---|
87 |
|
---|
88 | MODULE_DEVICE_TABLE(pci, snd_cs46xx_ids);
|
---|
89 |
|
---|
90 | static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci,
|
---|
91 | const struct pci_device_id *pci_id)
|
---|
92 | {
|
---|
93 | static int dev;
|
---|
94 | snd_card_t *card;
|
---|
95 | cs46xx_t *chip;
|
---|
96 | int err;
|
---|
97 |
|
---|
98 | if (dev >= SNDRV_CARDS)
|
---|
99 | return -ENODEV;
|
---|
100 | if (!enable[dev]) {
|
---|
101 | dev++;
|
---|
102 | return -ENOENT;
|
---|
103 | }
|
---|
104 |
|
---|
105 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
---|
106 | if (card == NULL)
|
---|
107 | return -ENOMEM;
|
---|
108 | if ((err = snd_cs46xx_create(card, pci,
|
---|
109 | external_amp[dev], thinkpad[dev],
|
---|
110 | &chip)) < 0) {
|
---|
111 | snd_card_free(card);
|
---|
112 | return err;
|
---|
113 | }
|
---|
114 | chip->accept_valid = mmap_valid[dev];
|
---|
115 | if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) {
|
---|
116 | snd_card_free(card);
|
---|
117 | return err;
|
---|
118 | }
|
---|
119 | #ifdef CONFIG_SND_CS46XX_NEW_DSP
|
---|
120 | if ((err = snd_cs46xx_pcm_rear(chip,1, NULL)) < 0) {
|
---|
121 | snd_card_free(card);
|
---|
122 | return err;
|
---|
123 | }
|
---|
124 | if ((err = snd_cs46xx_pcm_iec958(chip,2,NULL)) < 0) {
|
---|
125 | snd_card_free(card);
|
---|
126 | return err;
|
---|
127 | }
|
---|
128 | #endif
|
---|
129 | if ((err = snd_cs46xx_mixer(chip)) < 0) {
|
---|
130 | snd_card_free(card);
|
---|
131 | return err;
|
---|
132 | }
|
---|
133 | #ifdef CONFIG_SND_CS46XX_NEW_DSP
|
---|
134 | if (chip->nr_ac97_codecs ==2) {
|
---|
135 | if ((err = snd_cs46xx_pcm_center_lfe(chip,3,NULL)) < 0) {
|
---|
136 | snd_card_free(card);
|
---|
137 | return err;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | #endif
|
---|
141 | if ((err = snd_cs46xx_midi(chip, 0, NULL)) < 0) {
|
---|
142 | snd_card_free(card);
|
---|
143 | return err;
|
---|
144 | }
|
---|
145 | if ((err = snd_cs46xx_start_dsp(chip)) < 0) {
|
---|
146 | snd_card_free(card);
|
---|
147 | return err;
|
---|
148 | }
|
---|
149 |
|
---|
150 |
|
---|
151 | snd_cs46xx_gameport(chip);
|
---|
152 |
|
---|
153 | strcpy(card->driver, "CS46xx");
|
---|
154 | strcpy(card->shortname, "Sound Fusion CS46xx");
|
---|
155 | sprintf(card->longname, "%s at 0x%lx/0x%lx, irq %i",
|
---|
156 | card->shortname,
|
---|
157 | chip->ba0_addr,
|
---|
158 | chip->ba1_addr,
|
---|
159 | chip->irq);
|
---|
160 |
|
---|
161 | if ((err = snd_card_register(card)) < 0) {
|
---|
162 | snd_card_free(card);
|
---|
163 | return err;
|
---|
164 | }
|
---|
165 |
|
---|
166 | pci_set_drvdata(pci, card);
|
---|
167 | dev++;
|
---|
168 | return 0;
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | static void __devexit snd_card_cs46xx_remove(struct pci_dev *pci)
|
---|
173 | {
|
---|
174 | snd_card_free(pci_get_drvdata(pci));
|
---|
175 | pci_set_drvdata(pci, NULL);
|
---|
176 | }
|
---|
177 |
|
---|
178 | static struct pci_driver driver = {
|
---|
179 | 0, 0, 0,
|
---|
180 | "Sound Fusion CS46xx",
|
---|
181 | snd_cs46xx_ids,
|
---|
182 | snd_card_cs46xx_probe,
|
---|
183 | snd_card_cs46xx_remove,
|
---|
184 | SND_PCI_PM_CALLBACKS
|
---|
185 | };
|
---|
186 |
|
---|
187 | static int __init alsa_card_cs46xx_init(void)
|
---|
188 | {
|
---|
189 | int err;
|
---|
190 |
|
---|
191 | if ((err = pci_module_init(&driver)) < 0) {
|
---|
192 | #ifdef MODULE
|
---|
193 | // printk(KERN_ERR "Sound Fusion CS46xx soundcard not found or device busy\n");
|
---|
194 | #endif
|
---|
195 | return err;
|
---|
196 | }
|
---|
197 | return 0;
|
---|
198 | }
|
---|
199 |
|
---|
200 | static void __exit alsa_card_cs46xx_exit(void)
|
---|
201 | {
|
---|
202 | pci_unregister_driver(&driver);
|
---|
203 | }
|
---|
204 |
|
---|
205 | module_init(alsa_card_cs46xx_init)
|
---|
206 | module_exit(alsa_card_cs46xx_exit)
|
---|
207 |
|
---|
208 | #ifndef MODULE
|
---|
209 |
|
---|
210 | /* format is: snd-cs46xx=snd_enable,snd_index,snd_id */
|
---|
211 |
|
---|
212 | static int __init alsa_card_cs46xx_setup(char *str)
|
---|
213 | {
|
---|
214 | static unsigned __initdata nr_dev = 0;
|
---|
215 |
|
---|
216 | if (nr_dev >= SNDRV_CARDS)
|
---|
217 | return 0;
|
---|
218 | (void)(get_option(&str,&enable[nr_dev]) == 2 &&
|
---|
219 | get_option(&str,&index[nr_dev]) == 2 &&
|
---|
220 | get_id(&str,&id[nr_dev]) == 2);
|
---|
221 | nr_dev++;
|
---|
222 | return 1;
|
---|
223 | }
|
---|
224 |
|
---|
225 | __setup("snd-cs46xx=", alsa_card_cs46xx_setup);
|
---|
226 |
|
---|
227 | #endif /* ifndef MODULE */
|
---|