/* * Initialise the EMUX Synth by creating a client and registering * a series of ports. * Each of the ports will contain the 16 midi channels. Applications * can connect to these ports to play midi data. */ int snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) { int i; snd_seq_port_callback_t pinfo; char tmpname[64]; sprintf(tmpname, "%s WaveTable", emu->name); emu->client = get_client(card, index, tmpname); if (emu->client < 0) { snd_printk("can't create client\n"); return -ENODEV; } if (emu->num_ports < 0) { snd_printk("seqports must be greater than zero\n"); emu->num_ports = 1; } else if (emu->num_ports >= SNDRV_EMUX_MAX_PORTS) { snd_printk("too many ports." "limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS); emu->num_ports = SNDRV_EMUX_MAX_PORTS; } memset(&pinfo, 0, sizeof(pinfo)); pinfo.owner = THIS_MODULE; pinfo.use = snd_emux_use; pinfo.unuse = snd_emux_unuse; pinfo.event_input = snd_emux_event_input; for (i = 0; i < emu->num_ports; i++) { snd_emux_port_t *p; sprintf(tmpname, "%s Port %d", emu->name, i); p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS, 0, &pinfo); if (p == NULL) { snd_printk("can't create port\n"); return -ENOMEM; } p->port_mode = SNDRV_EMUX_PORT_MODE_MIDI; snd_emux_init_port(p); emu->ports[i] = p->chset.port; emu->portptrs[i] = p; } return 0; }
/* * 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_port_t *p; snd_emux_t *emu; p = private_data; snd_assert(p != NULL, return -EINVAL); emu = p->emu; snd_assert(emu != NULL, return -EINVAL); down(&emu->register_mutex); snd_emux_init_port(p); snd_emux_inc_count(emu); up(&emu->register_mutex); return 0; }
/* * Routine that is called upon a first use of a particular port */ static int snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info) { 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); mutex_lock(&emu->register_mutex); snd_emux_init_port(p); snd_emux_inc_count(emu); mutex_unlock(&emu->register_mutex); return 0; }
/* * Routine that is called upon a first use of a particular port */ static int snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info) { struct snd_emux_port *p; struct snd_emux *emu; p = private_data; if (snd_BUG_ON(!p)) return -EINVAL; emu = p->emu; if (snd_BUG_ON(!emu)) return -EINVAL; mutex_lock(&emu->register_mutex); snd_emux_init_port(p); snd_emux_inc_count(emu); mutex_unlock(&emu->register_mutex); return 0; }