~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/emu10k1/emu10k1.c

Version: ~ [ linux-5.9 ] ~ [ linux-5.8.14 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.70 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.150 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.200 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.238 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.238 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  The driver for the EMU10K1 (SB Live!) 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 #include <sound/driver.h>
 23 #include <linux/init.h>
 24 #include <linux/pci.h>
 25 #include <linux/time.h>
 26 #include <sound/core.h>
 27 #include <sound/emu10k1.h>
 28 #define SNDRV_GET_ID
 29 #include <sound/initval.h>
 30 
 31 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 32 MODULE_DESCRIPTION("EMU10K1");
 33 MODULE_LICENSE("GPL");
 34 MODULE_CLASSES("{sound}");
 35 MODULE_DEVICES("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
 36                "{Creative Labs,SB Audigy}}");
 37 
 38 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
 39 #define ENABLE_SYNTH
 40 #include <sound/emu10k1_synth.h>
 41 #endif
 42 
 43 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
 44 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
 45 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
 46 static int extin[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 47 static int extout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 48 static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
 49 static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
 50 static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
 51 static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 52 
 53 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 54 MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard.");
 55 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
 56 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
 57 MODULE_PARM_DESC(id, "ID string for the EMU10K1 soundcard.");
 58 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
 59 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 60 MODULE_PARM_DESC(enable, "Enable the EMU10K1 soundcard.");
 61 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
 62 MODULE_PARM(extin, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 63 MODULE_PARM_DESC(extin, "Available external inputs for FX8010. Zero=default.");
 64 MODULE_PARM_SYNTAX(extin, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
 65 MODULE_PARM(extout, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 66 MODULE_PARM_DESC(extout, "Available external outputs for FX8010. Zero=default.");
 67 MODULE_PARM_SYNTAX(extout, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
 68 MODULE_PARM(seq_ports, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 69 MODULE_PARM_DESC(seq_ports, "Allocated sequencer ports for internal synthesizer.");
 70 MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED "allows:{{0,32}}");
 71 MODULE_PARM(max_synth_voices, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 72 MODULE_PARM_DESC(max_synth_voices, "Maximum number of voices for WaveTable.");
 73 MODULE_PARM_SYNTAX(max_synth_voices, SNDRV_ENABLED);
 74 MODULE_PARM(max_buffer_size, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 75 MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB.");
 76 MODULE_PARM_SYNTAX(max_buffer_size, SNDRV_ENABLED);
 77 MODULE_PARM(enable_ir, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 78 MODULE_PARM_DESC(enable_ir, "Enable IR.");
 79 MODULE_PARM_SYNTAX(enable_ir, SNDRV_ENABLE_DESC);
 80 
 81 static struct pci_device_id snd_emu10k1_ids[] = {
 82         { 0x1102, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* EMU10K1 */
 83         { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* Dell OEM version (EMU10K1) */
 84         { 0x1102, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },    /* Audigy */
 85         { 0, }
 86 };
 87 
 88 MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids);
 89 
 90 static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
 91                                             const struct pci_device_id *pci_id)
 92 {
 93         static int dev;
 94         snd_card_t *card;
 95         emu10k1_t *emu;
 96 #ifdef ENABLE_SYNTH
 97         snd_seq_device_t *wave = NULL;
 98 #endif
 99         int err;
100 
101         if (dev >= SNDRV_CARDS)
102                 return -ENODEV;
103         if (!enable[dev]) {
104                 dev++;
105                 return -ENOENT;
106         }
107 
108         card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
109         if (card == NULL)
110                 return -ENOMEM;
111         if (max_buffer_size[dev] < 32)
112                 max_buffer_size[dev] = 32;
113         else if (max_buffer_size[dev] > 1024)
114                 max_buffer_size[dev] = 1024;
115         if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev],
116                                       (long)max_buffer_size[dev] * 1024 * 1024,
117                                       enable_ir[dev],
118                                       &emu)) < 0) {
119                 snd_card_free(card);
120                 return err;
121         }               
122         if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) {
123                 snd_card_free(card);
124                 return err;
125         }               
126         if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) {
127                 snd_card_free(card);
128                 return err;
129         }               
130         if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) {
131                 snd_card_free(card);
132                 return err;
133         }               
134         if ((err = snd_emu10k1_fx8010_pcm(emu, 3, NULL)) < 0) {
135                 snd_card_free(card);
136                 return err;
137         }               
138         if ((err = snd_emu10k1_mixer(emu)) < 0) {
139                 snd_card_free(card);
140                 return err;
141         }
142         if (emu->audigy) {
143                 if ((err = snd_emu10k1_audigy_midi(emu)) < 0) {
144                         snd_card_free(card);
145                         return err;
146                 }
147         } else {
148                 if ((err = snd_emu10k1_midi(emu)) < 0) {
149                         snd_card_free(card);
150                         return err;
151                 }
152         }
153         if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) {
154                 snd_card_free(card);
155                 return err;
156         }
157 #ifdef ENABLE_SYNTH
158         if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
159                                sizeof(snd_emu10k1_synth_arg_t), &wave) < 0 ||
160             wave == NULL) {
161                 snd_printk("can't initialize Emu10k1 wavetable synth\n");
162         } else {
163                 snd_emu10k1_synth_arg_t *arg;
164                 arg = SNDRV_SEQ_DEVICE_ARGPTR(wave);
165                 strcpy(wave->name, "Emu-10k1 Synth");
166                 arg->hwptr = emu;
167                 arg->index = 1;
168                 arg->seq_ports = seq_ports[dev];
169                 arg->max_voices = max_synth_voices[dev];
170         }
171 #endif
172  
173         if (emu->audigy && (emu->revision == 4) ) {
174                 strcpy(card->driver, "Audigy2");
175                 strcpy(card->shortname, "Sound Blaster Audigy2");
176         } else if (emu->audigy) {
177                 strcpy(card->driver, "Audigy");
178                 strcpy(card->shortname, "Sound Blaster Audigy");
179         } else if (emu->APS) {
180                 strcpy(card->driver, "E-mu APS");
181                 strcpy(card->shortname, "E-mu APS");
182         } else {
183                 strcpy(card->driver, "EMU10K1");
184                 strcpy(card->shortname, "Sound Blaster Live!");
185         }
186         sprintf(card->longname, "%s (rev.%d) at 0x%lx, irq %i", card->shortname, emu->revision, emu->port, emu->irq);
187 
188         if ((err = snd_card_register(card)) < 0) {
189                 snd_card_free(card);
190                 return err;
191         }
192         pci_set_drvdata(pci, card);
193         dev++;
194         return 0;
195 }
196 
197 static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci)
198 {
199         snd_card_free(pci_get_drvdata(pci));
200         pci_set_drvdata(pci, NULL);
201 }
202 
203 static struct pci_driver driver = {
204         .name = "EMU10K1_Audigy",
205         .id_table = snd_emu10k1_ids,
206         .probe = snd_card_emu10k1_probe,
207         .remove = __devexit_p(snd_card_emu10k1_remove),
208 };
209 
210 static int __init alsa_card_emu10k1_init(void)
211 {
212         int err;
213 
214         if ((err = pci_module_init(&driver)) < 0) {
215 #ifdef MODULE
216                 printk(KERN_ERR "EMU10K1/Audigy soundcard not found or device busy\n");
217 #endif
218                 return err;
219         }
220         return 0;
221 }
222 
223 static void __exit alsa_card_emu10k1_exit(void)
224 {
225         pci_unregister_driver(&driver);
226 }
227 
228 module_init(alsa_card_emu10k1_init)
229 module_exit(alsa_card_emu10k1_exit)
230 
231 #ifndef MODULE
232 
233 /* format is: snd-emu10k1=enable,index,id,
234                           seq_ports,max_synth_voices */
235 
236 static int __init alsa_card_emu10k1_setup(char *str)
237 {
238         static unsigned __initdata nr_dev = 0;
239 
240         if (nr_dev >= SNDRV_CARDS)
241                 return 0;
242         (void)(get_option(&str,&enable[nr_dev]) == 2 &&
243                get_option(&str,&index[nr_dev]) == 2 &&
244                get_id(&str,&id[nr_dev]) == 2 &&
245                get_option(&str,&seq_ports[nr_dev]) == 2 &&
246                get_option(&str,&max_synth_voices[nr_dev]) == 2);
247         nr_dev++;
248         return 1;
249 }
250 
251 __setup("snd-emu10k1=", alsa_card_emu10k1_setup);
252 
253 #endif /* ifndef MODULE */
254 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp