30 #include <linux/slab.h>
31 #include <linux/errno.h>
32 #include <linux/string.h>
33 #include <linux/module.h>
45 static int output_buffer_size =
PAGE_SIZE;
83 if (substream ==
NULL)
89 memset(&ev, 0,
sizeof(ev));
90 while (runtime->
avail > 0) {
108 memset(&ev, 0,
sizeof(ev));
122 if ((tmp = runtime->
avail) < count) {
123 if (printk_ratelimit())
136 unsigned char msg[10];
143 if (substream ==
NULL)
159 if (dump_midi(substream, msg, len) < 0)
166 static int snd_seq_midisynth_new(
struct seq_midisynth *msynth,
198 params.buffer_size = input_buffer_size;
204 runtime->
event = snd_midi_input_event;
239 params.buffer_size = output_buffer_size;
240 params.no_active_sensing = 1;
261 static void snd_seq_midisynth_delete(
struct seq_midisynth *msynth)
306 if (ports < input_count)
316 client = synths[card->
number];
317 if (client ==
NULL) {
319 client = kzalloc(
sizeof(*client),
GFP_KERNEL);
320 if (client ==
NULL) {
328 (
const char *)card->
shortname :
"External MIDI");
342 for (p = 0; p < ports; p++) {
345 if (snd_seq_midisynth_new(ms, card, device, p) < 0)
349 memset(port, 0,
sizeof(*port));
353 memset(info, 0,
sizeof(*info));
362 if (! port->
name[0]) {
387 memset(&pcallbacks, 0,
sizeof(pcallbacks));
389 pcallbacks.private_data =
ms;
390 pcallbacks.subscribe = midisynth_subscribe;
391 pcallbacks.unsubscribe = midisynth_unsubscribe;
392 pcallbacks.use = midisynth_use;
393 pcallbacks.unuse = midisynth_unuse;
394 pcallbacks.event_input = event_process_midi;
395 port->
kernel = &pcallbacks;
396 if (rmidi->
ops && rmidi->
ops->get_port_info)
397 rmidi->
ops->get_port_info(rmidi, p, port);
404 client->
ports[device] = msynth;
414 if (msynth !=
NULL) {
415 for (p = 0; p < ports; p++)
416 snd_seq_midisynth_delete(&msynth[p]);
436 int device = dev->
device,
p, ports;
439 client = synths[card->
number];
446 msynth = client->
ports[device];
448 for (p = 0; p < ports; p++)
449 snd_seq_midisynth_delete(&msynth[p]);
462 static int __init alsa_seq_midi_init(
void)
465 snd_seq_midisynth_register_port,
466 snd_seq_midisynth_unregister_port,
468 memset(&synths, 0,
sizeof(synths));
475 static void __exit alsa_seq_midi_exit(
void)