aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1/emu10k1_synth.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/emu10k1/emu10k1_synth.c')
-rw-r--r--sound/pci/emu10k1/emu10k1_synth.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/sound/pci/emu10k1/emu10k1_synth.c b/sound/pci/emu10k1/emu10k1_synth.c
new file mode 100644
index 000000000000..8bd58d1dcc26
--- /dev/null
+++ b/sound/pci/emu10k1/emu10k1_synth.c
@@ -0,0 +1,120 @@
1/*
2 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
3 *
4 * Routines for control of EMU10K1 WaveTable synth
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#include "emu10k1_synth_local.h"
22#include <linux/init.h>
23
24MODULE_AUTHOR("Takashi Iwai");
25MODULE_DESCRIPTION("Routines for control of EMU10K1 WaveTable synth");
26MODULE_LICENSE("GPL");
27
28/*
29 * create a new hardware dependent device for Emu10k1
30 */
31static int snd_emu10k1_synth_new_device(snd_seq_device_t *dev)
32{
33 snd_emux_t *emu;
34 emu10k1_t *hw;
35 snd_emu10k1_synth_arg_t *arg;
36 unsigned long flags;
37
38 arg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
39 if (arg == NULL)
40 return -EINVAL;
41
42 if (arg->seq_ports <= 0)
43 return 0; /* nothing */
44 if (arg->max_voices < 1)
45 arg->max_voices = 1;
46 else if (arg->max_voices > 64)
47 arg->max_voices = 64;
48
49 if (snd_emux_new(&emu) < 0)
50 return -ENOMEM;
51
52 snd_emu10k1_ops_setup(emu);
53 emu->hw = hw = arg->hwptr;
54 emu->max_voices = arg->max_voices;
55 emu->num_ports = arg->seq_ports;
56 emu->pitch_shift = -501;
57 emu->memhdr = hw->memhdr;
58 emu->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2; /* maximum two ports */
59 emu->midi_devidx = hw->audigy ? 2 : 1; /* audigy has two external midis */
60 emu->linear_panning = 0;
61 emu->hwdep_idx = 2; /* FIXED */
62
63 if (snd_emux_register(emu, dev->card, arg->index, "Emu10k1") < 0) {
64 snd_emux_free(emu);
65 emu->hw = NULL;
66 return -ENOMEM;
67 }
68
69 spin_lock_irqsave(&hw->voice_lock, flags);
70 hw->synth = emu;
71 hw->get_synth_voice = snd_emu10k1_synth_get_voice;
72 spin_unlock_irqrestore(&hw->voice_lock, flags);
73
74 dev->driver_data = emu;
75
76 return 0;
77}
78
79static int snd_emu10k1_synth_delete_device(snd_seq_device_t *dev)
80{
81 snd_emux_t *emu;
82 emu10k1_t *hw;
83 unsigned long flags;
84
85 if (dev->driver_data == NULL)
86 return 0; /* not registered actually */
87
88 emu = dev->driver_data;
89
90 hw = emu->hw;
91 spin_lock_irqsave(&hw->voice_lock, flags);
92 hw->synth = NULL;
93 hw->get_synth_voice = NULL;
94 spin_unlock_irqrestore(&hw->voice_lock, flags);
95
96 snd_emux_free(emu);
97 return 0;
98}
99
100/*
101 * INIT part
102 */
103
104static int __init alsa_emu10k1_synth_init(void)
105{
106
107 static snd_seq_dev_ops_t ops = {
108 snd_emu10k1_synth_new_device,
109 snd_emu10k1_synth_delete_device,
110 };
111 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, sizeof(snd_emu10k1_synth_arg_t));
112}
113
114static void __exit alsa_emu10k1_synth_exit(void)
115{
116 snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH);
117}
118
119module_init(alsa_emu10k1_synth_init)
120module_exit(alsa_emu10k1_synth_exit)