aboutsummaryrefslogtreecommitdiff
path: root/sound/core/seq/seq_midi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/seq/seq_midi.c')
-rw-r--r--sound/core/seq/seq_midi.c132
1 files changed, 60 insertions, 72 deletions
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
index f89f40f4487..ce0df86157d 100644
--- a/sound/core/seq/seq_midi.c
+++ b/sound/core/seq/seq_midi.c
@@ -51,40 +51,40 @@ module_param(input_buffer_size, int, 0644);
MODULE_PARM_DESC(input_buffer_size, "Input buffer size in bytes.");
/* data for this midi synth driver */
-typedef struct {
- snd_card_t *card;
+struct seq_midisynth {
+ struct snd_card *card;
int device;
int subdevice;
- snd_rawmidi_file_t input_rfile;
- snd_rawmidi_file_t output_rfile;
+ struct snd_rawmidi_file input_rfile;
+ struct snd_rawmidi_file output_rfile;
int seq_client;
int seq_port;
- snd_midi_event_t *parser;
-} seq_midisynth_t;
+ struct snd_midi_event *parser;
+};
-typedef struct {
+struct seq_midisynth_client {
int seq_client;
int num_ports;
int ports_per_device[SNDRV_RAWMIDI_DEVICES];
- seq_midisynth_t *ports[SNDRV_RAWMIDI_DEVICES];
-} seq_midisynth_client_t;
+ struct seq_midisynth *ports[SNDRV_RAWMIDI_DEVICES];
+};
-static seq_midisynth_client_t *synths[SNDRV_CARDS];
+static struct seq_midisynth_client *synths[SNDRV_CARDS];
static DECLARE_MUTEX(register_mutex);
/* handle rawmidi input event (MIDI v1.0 stream) */
-static void snd_midi_input_event(snd_rawmidi_substream_t * substream)
+static void snd_midi_input_event(struct snd_rawmidi_substream *substream)
{
- snd_rawmidi_runtime_t *runtime;
- seq_midisynth_t *msynth;
- snd_seq_event_t ev;
+ struct snd_rawmidi_runtime *runtime;
+ struct seq_midisynth *msynth;
+ struct snd_seq_event ev;
char buf[16], *pbuf;
long res, count;
if (substream == NULL)
return;
runtime = substream->runtime;
- msynth = (seq_midisynth_t *) runtime->private_data;
+ msynth = runtime->private_data;
if (msynth == NULL)
return;
memset(&ev, 0, sizeof(ev));
@@ -112,9 +112,9 @@ static void snd_midi_input_event(snd_rawmidi_substream_t * substream)
}
}
-static int dump_midi(snd_rawmidi_substream_t *substream, const char *buf, int count)
+static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, int count)
{
- snd_rawmidi_runtime_t *runtime;
+ struct snd_rawmidi_runtime *runtime;
int tmp;
snd_assert(substream != NULL || buf != NULL, return -EINVAL);
@@ -128,12 +128,12 @@ static int dump_midi(snd_rawmidi_substream_t *substream, const char *buf, int co
return 0;
}
-static int event_process_midi(snd_seq_event_t * ev, int direct,
+static int event_process_midi(struct snd_seq_event *ev, int direct,
void *private_data, int atomic, int hop)
{
- seq_midisynth_t *msynth = (seq_midisynth_t *) private_data;
+ struct seq_midisynth *msynth = private_data;
unsigned char msg[10]; /* buffer for constructing midi messages */
- snd_rawmidi_substream_t *substream;
+ struct snd_rawmidi_substream *substream;
int len;
snd_assert(msynth != NULL, return -EINVAL);
@@ -161,8 +161,8 @@ static int event_process_midi(snd_seq_event_t * ev, int direct,
}
-static int snd_seq_midisynth_new(seq_midisynth_t *msynth,
- snd_card_t *card,
+static int snd_seq_midisynth_new(struct seq_midisynth *msynth,
+ struct snd_card *card,
int device,
int subdevice)
{
@@ -175,15 +175,18 @@ static int snd_seq_midisynth_new(seq_midisynth_t *msynth,
}
/* open associated midi device for input */
-static int midisynth_subscribe(void *private_data, snd_seq_port_subscribe_t *info)
+static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribe *info)
{
int err;
- seq_midisynth_t *msynth = (seq_midisynth_t *)private_data;
- snd_rawmidi_runtime_t *runtime;
- snd_rawmidi_params_t params;
+ struct seq_midisynth *msynth = private_data;
+ struct snd_rawmidi_runtime *runtime;
+ struct snd_rawmidi_params params;
/* open midi port */
- if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_INPUT, &msynth->input_rfile)) < 0) {
+ if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device,
+ msynth->subdevice,
+ SNDRV_RAWMIDI_LFLG_INPUT,
+ &msynth->input_rfile)) < 0) {
snd_printd("midi input open failed!!!\n");
return err;
}
@@ -203,10 +206,10 @@ static int midisynth_subscribe(void *private_data, snd_seq_port_subscribe_t *inf
}
/* close associated midi device for input */
-static int midisynth_unsubscribe(void *private_data, snd_seq_port_subscribe_t *info)
+static int midisynth_unsubscribe(void *private_data, struct snd_seq_port_subscribe *info)
{
int err;
- seq_midisynth_t *msynth = (seq_midisynth_t *)private_data;
+ struct seq_midisynth *msynth = private_data;
snd_assert(msynth->input_rfile.input != NULL, return -EINVAL);
err = snd_rawmidi_kernel_release(&msynth->input_rfile);
@@ -214,14 +217,17 @@ static int midisynth_unsubscribe(void *private_data, snd_seq_port_subscribe_t *i
}
/* open associated midi device for output */
-static int midisynth_use(void *private_data, snd_seq_port_subscribe_t *info)
+static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info)
{
int err;
- seq_midisynth_t *msynth = (seq_midisynth_t *)private_data;
- snd_rawmidi_params_t params;
+ struct seq_midisynth *msynth = private_data;
+ struct snd_rawmidi_params params;
/* open midi port */
- if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_OUTPUT, &msynth->output_rfile)) < 0) {
+ if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device,
+ msynth->subdevice,
+ SNDRV_RAWMIDI_LFLG_OUTPUT,
+ &msynth->output_rfile)) < 0) {
snd_printd("midi output open failed!!!\n");
return err;
}
@@ -237,9 +243,9 @@ static int midisynth_use(void *private_data, snd_seq_port_subscribe_t *info)
}
/* close associated midi device for output */
-static int midisynth_unuse(void *private_data, snd_seq_port_subscribe_t *info)
+static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *info)
{
- seq_midisynth_t *msynth = (seq_midisynth_t *)private_data;
+ struct seq_midisynth *msynth = private_data;
unsigned char buf = 0xff; /* MIDI reset */
snd_assert(msynth->output_rfile.output != NULL, return -EINVAL);
@@ -250,7 +256,7 @@ static int midisynth_unuse(void *private_data, snd_seq_port_subscribe_t *info)
}
/* delete given midi synth port */
-static void snd_seq_midisynth_delete(seq_midisynth_t *msynth)
+static void snd_seq_midisynth_delete(struct seq_midisynth *msynth)
{
if (msynth == NULL)
return;
@@ -264,34 +270,18 @@ static void snd_seq_midisynth_delete(seq_midisynth_t *msynth)
snd_midi_event_free(msynth->parser);
}
-/* set our client name */
-static int set_client_name(seq_midisynth_client_t *client, snd_card_t *card,
- snd_rawmidi_info_t *rmidi)
-{
- snd_seq_client_info_t cinfo;
- const char *name;
-
- memset(&cinfo, 0, sizeof(cinfo));
- cinfo.client = client->seq_client;
- cinfo.type = KERNEL_CLIENT;
- name = rmidi->name[0] ? (const char *)rmidi->name : "External MIDI";
- strlcpy(cinfo.name, name, sizeof(cinfo.name));
- return snd_seq_kernel_client_ctl(client->seq_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo);
-}
-
/* register new midi synth port */
static int
-snd_seq_midisynth_register_port(snd_seq_device_t *dev)
+snd_seq_midisynth_register_port(struct snd_seq_device *dev)
{
- seq_midisynth_client_t *client;
- seq_midisynth_t *msynth, *ms;
- snd_seq_port_info_t *port;
- snd_rawmidi_info_t *info;
+ struct seq_midisynth_client *client;
+ struct seq_midisynth *msynth, *ms;
+ struct snd_seq_port_info *port;
+ struct snd_rawmidi_info *info;
int newclient = 0;
unsigned int p, ports;
- snd_seq_client_callback_t callbacks;
- snd_seq_port_callback_t pcallbacks;
- snd_card_t *card = dev->card;
+ struct snd_seq_port_callback pcallbacks;
+ struct snd_card *card = dev->card;
int device = dev->device;
unsigned int input_count = 0, output_count = 0;
@@ -328,21 +318,19 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev)
kfree(info);
return -ENOMEM;
}
- memset(&callbacks, 0, sizeof(callbacks));
- callbacks.private_data = client;
- callbacks.allow_input = callbacks.allow_output = 1;
- client->seq_client = snd_seq_create_kernel_client(card, 0, &callbacks);
+ client->seq_client =
+ snd_seq_create_kernel_client(
+ card, 0, "%s", info->name[0] ?
+ (const char *)info->name : "External MIDI");
if (client->seq_client < 0) {
kfree(client);
up(&register_mutex);
kfree(info);
return -ENOMEM;
}
- set_client_name(client, card, info);
- } else if (device == 0)
- set_client_name(client, card, info); /* use the first device's name */
+ }
- msynth = kcalloc(ports, sizeof(seq_midisynth_t), GFP_KERNEL);
+ msynth = kcalloc(ports, sizeof(struct seq_midisynth), GFP_KERNEL);
port = kmalloc(sizeof(*port), GFP_KERNEL);
if (msynth == NULL || port == NULL)
goto __nomem;
@@ -432,11 +420,11 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev)
/* release midi synth port */
static int
-snd_seq_midisynth_unregister_port(snd_seq_device_t *dev)
+snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
{
- seq_midisynth_client_t *client;
- seq_midisynth_t *msynth;
- snd_card_t *card = dev->card;
+ struct seq_midisynth_client *client;
+ struct seq_midisynth *msynth;
+ struct snd_card *card = dev->card;
int device = dev->device, p, ports;
down(&register_mutex);
@@ -465,7 +453,7 @@ snd_seq_midisynth_unregister_port(snd_seq_device_t *dev)
static int __init alsa_seq_midi_init(void)
{
- static snd_seq_dev_ops_t ops = {
+ static struct snd_seq_dev_ops ops = {
snd_seq_midisynth_register_port,
snd_seq_midisynth_unregister_port,
};