31 #include <linux/time.h>
32 #include <linux/export.h>
48 static int voice_alloc(
struct snd_emu10k1 *
emu,
int type,
int number,
49 struct snd_emu10k1_voice **rvoice)
51 struct snd_emu10k1_voice *
voice;
52 int i,
j,
k, first_voice, last_voice,
skip;
55 first_voice = last_voice = 0;
56 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) {
64 if ((number == 2) && (i % 2)) {
70 for (k = 0; k < number; k++) {
71 voice = &emu->voices[(i+
k) % NUM_G];
80 last_voice = (i + number) % NUM_G;
81 emu->next_free_voice = last_voice;
86 if (first_voice == last_voice)
89 for (i = 0; i < number; i++) {
90 voice = &emu->voices[(first_voice +
i) % NUM_G];
111 *rvoice = &emu->voices[first_voice];
116 struct snd_emu10k1_voice **rvoice)
128 result = voice_alloc(emu, type, number, rvoice);
129 if (result == 0 || type == EMU10K1_SYNTH || type == EMU10K1_MIDI)
133 if (emu->get_synth_voice) {
134 result = emu->get_synth_voice(emu);
136 struct snd_emu10k1_voice *pvoice = &emu->voices[
result];
137 pvoice->interrupt =
NULL;
138 pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
145 spin_unlock_irqrestore(&emu->voice_lock, flags);
153 struct snd_emu10k1_voice *pvoice)
160 pvoice->interrupt =
NULL;
161 pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
164 spin_unlock_irqrestore(&emu->voice_lock, flags);