X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fsynth%2Femux%2Femux_seq.c;h=d176cc01742d2069a400bfaf5585bfed1fb2e052;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;hp=4b91722001059fc39db46cf34dbd3eefd07cbf3c;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 4b9172200..d176cc017 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -25,15 +25,14 @@ /* Prototypes for static functions */ static void free_port(void *private); -static void snd_emux_init_port(snd_emux_port_t *p); -static int snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info); -static int snd_emux_unuse(void *private_data, snd_seq_port_subscribe_t *info); -static int get_client(snd_card_t *card, int index, char *name); +static void snd_emux_init_port(struct snd_emux_port *p); +static int snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info); +static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info); /* * MIDI emulation operators */ -static snd_midi_op_t emux_ops = { +static struct snd_midi_op emux_ops = { snd_emux_note_on, snd_emux_note_off, snd_emux_key_press, @@ -56,7 +55,8 @@ static snd_midi_op_t emux_ops = { SNDRV_SEQ_PORT_TYPE_MIDI_GM |\ SNDRV_SEQ_PORT_TYPE_MIDI_GS |\ SNDRV_SEQ_PORT_TYPE_MIDI_XG |\ - SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE) + SNDRV_SEQ_PORT_TYPE_HARDWARE |\ + SNDRV_SEQ_PORT_TYPE_SYNTHESIZER) /* * Initialise the EMUX Synth by creating a client and registering @@ -65,14 +65,14 @@ static snd_midi_op_t emux_ops = { * can connect to these ports to play midi data. */ int -snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) +snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index) { int i; - snd_seq_port_callback_t pinfo; + struct snd_seq_port_callback pinfo; char tmpname[64]; - sprintf(tmpname, "%s WaveTable", emu->name); - emu->client = get_client(card, index, tmpname); + emu->client = snd_seq_create_kernel_client(card, index, + "%s WaveTable", emu->name); if (emu->client < 0) { snd_printk("can't create client\n"); return -ENODEV; @@ -94,7 +94,7 @@ snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) pinfo.event_input = snd_emux_event_input; for (i = 0; i < emu->num_ports; i++) { - snd_emux_port_t *p; + struct snd_emux_port *p; sprintf(tmpname, "%s Port %d", emu->name, i); p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS, @@ -119,17 +119,17 @@ snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) * destroy the kernel client. */ void -snd_emux_detach_seq(snd_emux_t *emu) +snd_emux_detach_seq(struct snd_emux *emu) { if (emu->voices) snd_emux_terminate_all(emu); - down(&emu->register_mutex); + mutex_lock(&emu->register_mutex); if (emu->client >= 0) { snd_seq_delete_kernel_client(emu->client); emu->client = -1; } - up(&emu->register_mutex); + mutex_unlock(&emu->register_mutex); } @@ -137,20 +137,20 @@ snd_emux_detach_seq(snd_emux_t *emu) * create a sequencer port and channel_set */ -snd_emux_port_t * -snd_emux_create_port(snd_emux_t *emu, char *name, - int max_channels, int oss_port, - snd_seq_port_callback_t *callback) +struct snd_emux_port * +snd_emux_create_port(struct snd_emux *emu, char *name, + int max_channels, int oss_port, + struct snd_seq_port_callback *callback) { - snd_emux_port_t *p; + struct snd_emux_port *p; int i, type, cap; /* Allocate structures for this channel */ - if ((p = kcalloc(1, sizeof(*p), GFP_KERNEL)) == NULL) { + if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) { snd_printk("no memory\n"); return NULL; } - p->chset.channels = kcalloc(max_channels, sizeof(snd_midi_channel_t), GFP_KERNEL); + p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL); if (p->chset.channels == NULL) { snd_printk("no memory\n"); kfree(p); @@ -190,15 +190,14 @@ snd_emux_create_port(snd_emux_t *emu, char *name, static void free_port(void *private_data) { - snd_emux_port_t *p; + struct snd_emux_port *p; p = private_data; if (p) { #ifdef SNDRV_EMUX_USE_RAW_EFFECT snd_emux_delete_effect(p); #endif - if (p->chset.channels) - kfree(p->chset.channels); + kfree(p->chset.channels); kfree(p); } } @@ -210,7 +209,7 @@ free_port(void *private_data) * initialize the port specific parameters */ static void -snd_emux_init_port(snd_emux_port_t *p) +snd_emux_init_port(struct snd_emux_port *p) { p->drum_flags = DEFAULT_DRUM_FLAGS; p->volume_atten = 0; @@ -223,7 +222,7 @@ snd_emux_init_port(snd_emux_port_t *p) * reset port */ void -snd_emux_reset_port(snd_emux_port_t *port) +snd_emux_reset_port(struct snd_emux_port *port) { int i; @@ -242,7 +241,7 @@ snd_emux_reset_port(snd_emux_port_t *port) port->ctrls[EMUX_MD_REALTIME_PAN] = 1; for (i = 0; i < port->chset.max_channels; i++) { - snd_midi_channel_t *chan = port->chset.channels + i; + struct snd_midi_channel *chan = port->chset.channels + i; chan->drum_channel = ((port->drum_flags >> i) & 1) ? 1 : 0; } } @@ -252,10 +251,10 @@ snd_emux_reset_port(snd_emux_port_t *port) * input sequencer event */ int -snd_emux_event_input(snd_seq_event_t *ev, int direct, void *private_data, +snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_emux_port_t *port; + struct snd_emux_port *port; port = private_data; snd_assert(port != NULL && ev != NULL, return -EINVAL); @@ -270,7 +269,7 @@ snd_emux_event_input(snd_seq_event_t *ev, int direct, void *private_data, * increment usage count */ int -snd_emux_inc_count(snd_emux_t *emu) +snd_emux_inc_count(struct snd_emux *emu) { emu->used++; if (!try_module_get(emu->ops.owner)) @@ -289,7 +288,7 @@ snd_emux_inc_count(snd_emux_t *emu) * decrease usage count */ void -snd_emux_dec_count(snd_emux_t *emu) +snd_emux_dec_count(struct snd_emux *emu) { module_put(emu->card->module); emu->used--; @@ -303,20 +302,20 @@ snd_emux_dec_count(snd_emux_t *emu) * Routine that is called upon a first use of a particular port */ static int -snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info) +snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info) { - snd_emux_port_t *p; - snd_emux_t *emu; + struct snd_emux_port *p; + struct snd_emux *emu; p = private_data; snd_assert(p != NULL, return -EINVAL); emu = p->emu; snd_assert(emu != NULL, return -EINVAL); - down(&emu->register_mutex); + mutex_lock(&emu->register_mutex); snd_emux_init_port(p); snd_emux_inc_count(emu); - up(&emu->register_mutex); + mutex_unlock(&emu->register_mutex); return 0; } @@ -324,58 +323,28 @@ snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info) * Routine that is called upon the last unuse() of a particular port. */ static int -snd_emux_unuse(void *private_data, snd_seq_port_subscribe_t *info) +snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - snd_emux_port_t *p; - snd_emux_t *emu; + struct snd_emux_port *p; + struct snd_emux *emu; p = private_data; snd_assert(p != NULL, return -EINVAL); emu = p->emu; snd_assert(emu != NULL, return -EINVAL); - down(&emu->register_mutex); + mutex_lock(&emu->register_mutex); snd_emux_sounds_off_all(p); snd_emux_dec_count(emu); - up(&emu->register_mutex); + mutex_unlock(&emu->register_mutex); return 0; } -/* - * Create a sequencer client - */ -static int -get_client(snd_card_t *card, int index, char *name) -{ - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; - int client; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = NULL; - callbacks.allow_input = 1; - callbacks.allow_output = 1; - - /* Find a free client, start from 1 as the MPU expects to use 0 */ - client = snd_seq_create_kernel_client(card, index, &callbacks); - if (client < 0) - return client; - - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; - strcpy(cinfo.name, name); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - - return client; -} - - /* * attach virtual rawmidi devices */ -int snd_emux_init_virmidi(snd_emux_t *emu, snd_card_t *card) +int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card) { int i; @@ -383,13 +352,13 @@ int snd_emux_init_virmidi(snd_emux_t *emu, snd_card_t *card) if (emu->midi_ports <= 0) return 0; - emu->vmidi = kcalloc(emu->midi_ports, sizeof(snd_rawmidi_t*), GFP_KERNEL); + emu->vmidi = kcalloc(emu->midi_ports, sizeof(struct snd_rawmidi *), GFP_KERNEL); if (emu->vmidi == NULL) return -ENOMEM; for (i = 0; i < emu->midi_ports; i++) { - snd_rawmidi_t *rmidi; - snd_virmidi_dev_t *rdev; + struct snd_rawmidi *rmidi; + struct snd_virmidi_dev *rdev; if (snd_virmidi_new(card, emu->midi_devidx + i, &rmidi) < 0) goto __error; rdev = rmidi->private_data; @@ -412,7 +381,7 @@ __error: return -ENOMEM; } -int snd_emux_delete_virmidi(snd_emux_t *emu) +int snd_emux_delete_virmidi(struct snd_emux *emu) { int i;