X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Fseq%2Fseq_virmidi.c;h=f4edec603b8f7036e464d8b91c6782751afa817d;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=6b4e630ace54108c6ce2d2bb4f012b4896845fb7;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 6b4e630ac..f4edec603 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -56,7 +56,8 @@ MODULE_LICENSE("GPL"); /* * initialize an event record */ -static void snd_virmidi_init_event(snd_virmidi_t *vmidi, snd_seq_event_t *ev) +static void snd_virmidi_init_event(struct snd_virmidi *vmidi, + struct snd_seq_event *ev) { memset(ev, 0, sizeof(*ev)); ev->source.port = vmidi->port; @@ -76,16 +77,17 @@ static void snd_virmidi_init_event(snd_virmidi_t *vmidi, snd_seq_event_t *ev) /* * decode input event and put to read buffer of each opened file */ -static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_t *ev) +static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev, + struct snd_seq_event *ev) { - snd_virmidi_t *vmidi; + struct snd_virmidi *vmidi; struct list_head *list; unsigned char msg[4]; int len; read_lock(&rdev->filelist_lock); list_for_each(list, &rdev->filelist) { - vmidi = list_entry(list, snd_virmidi_t, list); + vmidi = list_entry(list, struct snd_virmidi, list); if (!vmidi->trigger) continue; if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { @@ -110,22 +112,23 @@ static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_ * handler of a remote port which is attached to the virmidi via * SNDRV_VIRMIDI_SEQ_ATTACH. */ -/* exported */ -int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) +#if 0 +int snd_virmidi_receive(struct snd_rawmidi *rmidi, struct snd_seq_event *ev) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = rmidi->private_data; return snd_virmidi_dev_receive_event(rdev, ev); } +#endif /* 0 */ /* * event handler of virmidi port */ -static int snd_virmidi_event_input(snd_seq_event_t *ev, int direct, +static int snd_virmidi_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!(rdev->flags & SNDRV_VIRMIDI_USE)) @@ -136,9 +139,9 @@ static int snd_virmidi_event_input(snd_seq_event_t *ev, int direct, /* * trigger rawmidi stream for input */ -static void snd_virmidi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_virmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; if (up) { vmidi->trigger = 1; @@ -150,9 +153,9 @@ static void snd_virmidi_input_trigger(snd_rawmidi_substream_t * substream, int u /* * trigger rawmidi stream for output */ -static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_virmidi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; int count, res; unsigned char buf[32], *pbuf; @@ -164,7 +167,7 @@ static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int return; /* ignored */ } if (vmidi->event.type != SNDRV_SEQ_EVENT_NONE) { - if (snd_seq_kernel_client_dispatch(vmidi->client, &vmidi->event, 0, 0) < 0) + if (snd_seq_kernel_client_dispatch(vmidi->client, &vmidi->event, in_atomic(), 0) < 0) return; vmidi->event.type = SNDRV_SEQ_EVENT_NONE; } @@ -183,7 +186,7 @@ static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int pbuf += res; count -= res; if (vmidi->event.type != SNDRV_SEQ_EVENT_NONE) { - if (snd_seq_kernel_client_dispatch(vmidi->client, &vmidi->event, 0, 0) < 0) + if (snd_seq_kernel_client_dispatch(vmidi->client, &vmidi->event, in_atomic(), 0) < 0) return; vmidi->event.type = SNDRV_SEQ_EVENT_NONE; } @@ -197,14 +200,14 @@ static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int /* * open rawmidi handle for input */ -static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream) +static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream) { - snd_virmidi_dev_t *rdev = substream->rmidi->private_data; - snd_rawmidi_runtime_t *runtime = substream->runtime; - snd_virmidi_t *vmidi; + struct snd_virmidi_dev *rdev = substream->rmidi->private_data; + struct snd_rawmidi_runtime *runtime = substream->runtime; + struct snd_virmidi *vmidi; unsigned long flags; - vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); + vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); if (vmidi == NULL) return -ENOMEM; vmidi->substream = substream; @@ -226,13 +229,13 @@ static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream) /* * open rawmidi handle for output */ -static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream) +static int snd_virmidi_output_open(struct snd_rawmidi_substream *substream) { - snd_virmidi_dev_t *rdev = substream->rmidi->private_data; - snd_rawmidi_runtime_t *runtime = substream->runtime; - snd_virmidi_t *vmidi; + struct snd_virmidi_dev *rdev = substream->rmidi->private_data; + struct snd_rawmidi_runtime *runtime = substream->runtime; + struct snd_virmidi *vmidi; - vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); + vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); if (vmidi == NULL) return -ENOMEM; vmidi->substream = substream; @@ -252,9 +255,9 @@ static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream) /* * close rawmidi handle for input */ -static int snd_virmidi_input_close(snd_rawmidi_substream_t * substream) +static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; snd_midi_event_free(vmidi->parser); list_del(&vmidi->list); substream->runtime->private_data = NULL; @@ -265,9 +268,9 @@ static int snd_virmidi_input_close(snd_rawmidi_substream_t * substream) /* * close rawmidi handle for output */ -static int snd_virmidi_output_close(snd_rawmidi_substream_t * substream) +static int snd_virmidi_output_close(struct snd_rawmidi_substream *substream) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; snd_midi_event_free(vmidi->parser); substream->runtime->private_data = NULL; kfree(vmidi); @@ -277,9 +280,10 @@ static int snd_virmidi_output_close(snd_rawmidi_substream_t * substream) /* * subscribe callback - allow output to rawmidi device */ -static int snd_virmidi_subscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_subscribe(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!try_module_get(rdev->card->module)) @@ -291,9 +295,10 @@ static int snd_virmidi_subscribe(void *private_data, snd_seq_port_subscribe_t *i /* * unsubscribe callback - disallow output to rawmidi device */ -static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_unsubscribe(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; @@ -305,9 +310,10 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t /* * use callback - allow input to rawmidi device */ -static int snd_virmidi_use(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_use(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!try_module_get(rdev->card->module)) @@ -319,9 +325,10 @@ static int snd_virmidi_use(void *private_data, snd_seq_port_subscribe_t *info) /* * unuse callback - disallow input to rawmidi device */ -static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_unuse(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; rdev->flags &= ~SNDRV_VIRMIDI_USE; @@ -334,13 +341,13 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) * Register functions */ -static snd_rawmidi_ops_t snd_virmidi_input_ops = { +static struct snd_rawmidi_ops snd_virmidi_input_ops = { .open = snd_virmidi_input_open, .close = snd_virmidi_input_close, .trigger = snd_virmidi_input_trigger, }; -static snd_rawmidi_ops_t snd_virmidi_output_ops = { +static struct snd_rawmidi_ops snd_virmidi_output_ops = { .open = snd_virmidi_output_open, .close = snd_virmidi_output_close, .trigger = snd_virmidi_output_trigger, @@ -349,43 +356,32 @@ static snd_rawmidi_ops_t snd_virmidi_output_ops = { /* * create a sequencer client and a port */ -static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) +static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) { int client; - snd_seq_client_callback_t callbacks; - snd_seq_port_callback_t pcallbacks; - snd_seq_client_info_t *info; - snd_seq_port_info_t *pinfo; + struct snd_seq_port_callback pcallbacks; + struct snd_seq_port_info *pinfo; int err; if (rdev->client >= 0) return 0; - info = kmalloc(sizeof(*info), GFP_KERNEL); pinfo = kmalloc(sizeof(*pinfo), GFP_KERNEL); - if (! info || ! pinfo) { + if (!pinfo) { err = -ENOMEM; goto __error; } - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = rdev; - callbacks.allow_input = 1; - callbacks.allow_output = 1; - client = snd_seq_create_kernel_client(rdev->card, rdev->device, &callbacks); + client = snd_seq_create_kernel_client(rdev->card, rdev->device, + "%s %d-%d", rdev->rmidi->name, + rdev->card->number, + rdev->device); if (client < 0) { err = client; goto __error; } rdev->client = client; - /* set client name */ - memset(info, 0, sizeof(*info)); - info->client = client; - info->type = KERNEL_CLIENT; - sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &info); - /* create a port */ memset(pinfo, 0, sizeof(*pinfo)); pinfo->addr.client = client; @@ -405,7 +401,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) pcallbacks.unuse = snd_virmidi_unuse; pcallbacks.event_input = snd_virmidi_event_input; pinfo->kernel = &pcallbacks; - err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, &pinfo); + err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, pinfo); if (err < 0) { snd_seq_delete_kernel_client(client); rdev->client = -1; @@ -416,7 +412,6 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) err = 0; /* success */ __error: - kfree(info); kfree(pinfo); return err; } @@ -425,7 +420,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) /* * release the sequencer client */ -static void snd_virmidi_dev_detach_seq(snd_virmidi_dev_t *rdev) +static void snd_virmidi_dev_detach_seq(struct snd_virmidi_dev *rdev) { if (rdev->client >= 0) { snd_seq_delete_kernel_client(rdev->client); @@ -436,9 +431,9 @@ static void snd_virmidi_dev_detach_seq(snd_virmidi_dev_t *rdev) /* * register the device */ -static int snd_virmidi_dev_register(snd_rawmidi_t *rmidi) +static int snd_virmidi_dev_register(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; int err; switch (rdev->seq_mode) { @@ -463,9 +458,9 @@ static int snd_virmidi_dev_register(snd_rawmidi_t *rmidi) /* * unregister the device */ -static int snd_virmidi_dev_unregister(snd_rawmidi_t *rmidi) +static int snd_virmidi_dev_unregister(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; if (rdev->seq_mode == SNDRV_VIRMIDI_SEQ_DISPATCH) snd_virmidi_dev_detach_seq(rdev); @@ -475,7 +470,7 @@ static int snd_virmidi_dev_unregister(snd_rawmidi_t *rmidi) /* * */ -static snd_rawmidi_global_ops_t snd_virmidi_global_ops = { +static struct snd_rawmidi_global_ops snd_virmidi_global_ops = { .dev_register = snd_virmidi_dev_register, .dev_unregister = snd_virmidi_dev_unregister, }; @@ -483,9 +478,9 @@ static snd_rawmidi_global_ops_t snd_virmidi_global_ops = { /* * free device */ -static void snd_virmidi_free(snd_rawmidi_t *rmidi) +static void snd_virmidi_free(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; kfree(rdev); } @@ -494,10 +489,10 @@ static void snd_virmidi_free(snd_rawmidi_t *rmidi) * */ /* exported */ -int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi) +int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi) { - snd_rawmidi_t *rmidi; - snd_virmidi_dev_t *rdev; + struct snd_rawmidi *rmidi; + struct snd_virmidi_dev *rdev; int err; *rrmidi = NULL; @@ -507,7 +502,7 @@ int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi) &rmidi)) < 0) return err; strcpy(rmidi->name, rmidi->id); - rdev = kcalloc(1, sizeof(*rdev), GFP_KERNEL); + rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); if (rdev == NULL) { snd_device_free(card, rmidi); return -ENOMEM; @@ -548,4 +543,3 @@ module_init(alsa_virmidi_init) module_exit(alsa_virmidi_exit) EXPORT_SYMBOL(snd_virmidi_new); -EXPORT_SYMBOL(snd_virmidi_receive);