static int snd_opl4_seq_new_device(struct snd_seq_device *dev) { struct snd_opl4 *opl4; int client; struct snd_seq_port_callback pcallbacks; opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (!opl4) return -EINVAL; if (snd_yrw801_detect(opl4) < 0) return -ENODEV; opl4->chset = snd_midi_channel_alloc_set(16); if (!opl4->chset) return -ENOMEM; opl4->chset->private_data = opl4; /* allocate new client */ client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num, "OPL4 Wavetable"); if (client < 0) { snd_midi_channel_free_set(opl4->chset); return client; } opl4->seq_client = client; opl4->chset->client = client; /* create new port */ memset(&pcallbacks, 0, sizeof(pcallbacks)); pcallbacks.owner = THIS_MODULE; pcallbacks.use = snd_opl4_seq_use; pcallbacks.unuse = snd_opl4_seq_unuse; pcallbacks.event_input = snd_opl4_seq_event_input; pcallbacks.private_free = snd_opl4_seq_free_port; pcallbacks.private_data = opl4; opl4->chset->port = snd_seq_event_port_attach(client, &pcallbacks, SNDRV_SEQ_PORT_CAP_WRITE | SNDRV_SEQ_PORT_CAP_SUBS_WRITE, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | SNDRV_SEQ_PORT_TYPE_MIDI_GM | SNDRV_SEQ_PORT_TYPE_HARDWARE | SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, 16, 24, "OPL4 Wavetable Port"); if (opl4->chset->port < 0) { int err = opl4->chset->port; snd_midi_channel_free_set(opl4->chset); snd_seq_delete_kernel_client(client); opl4->seq_client = -1; return err; } return 0; }
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) { snd_emux_port_t *p; int i, type, cap; /* Allocate structures for this channel */ if ((p = kcalloc(1, 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); if (p->chset.channels == NULL) { snd_printk("no memory\n"); kfree(p); return NULL; } for (i = 0; i < max_channels; i++) p->chset.channels[i].number = i; p->chset.private_data = p; p->chset.max_channels = max_channels; p->emu = emu; p->chset.client = emu->client; #ifdef SNDRV_EMUX_USE_RAW_EFFECT snd_emux_create_effect(p); #endif callback->private_free = free_port; callback->private_data = p; cap = SNDRV_SEQ_PORT_CAP_WRITE; if (oss_port) { type = SNDRV_SEQ_PORT_TYPE_SPECIFIC; } else { type = DEFAULT_MIDI_TYPE; cap |= SNDRV_SEQ_PORT_CAP_SUBS_WRITE; } p->chset.port = snd_seq_event_port_attach(emu->client, callback, cap, type, max_channels, emu->max_voices, name); return p; }
static int snd_opl3_synth_create_port(struct snd_opl3 * opl3) { struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; voices = (opl3->hardware < OPL3_HW_OPL3) ? MAX_OPL2_VOICES : MAX_OPL3_VOICES; opl3->chset = snd_midi_channel_alloc_set(16); if (opl3->chset == NULL) return -ENOMEM; opl3->chset->private_data = opl3; memset(&callbacks, 0, sizeof(callbacks)); callbacks.owner = THIS_MODULE; callbacks.use = snd_opl3_synth_use; callbacks.unuse = snd_opl3_synth_unuse; callbacks.event_input = snd_opl3_synth_event_input; callbacks.private_free = snd_opl3_synth_free_port; callbacks.private_data = opl3; opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; sprintf(name, "OPL%i FM Port", opl_ver); opl3->chset->client = opl3->seq_client; opl3->chset->port = snd_seq_event_port_attach(opl3->seq_client, &callbacks, SNDRV_SEQ_PORT_CAP_WRITE | SNDRV_SEQ_PORT_CAP_SUBS_WRITE, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | SNDRV_SEQ_PORT_TYPE_MIDI_GM | SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE | SNDRV_SEQ_PORT_TYPE_HARDWARE | SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, 16, voices, name); if (opl3->chset->port < 0) { int port; port = opl3->chset->port; snd_midi_channel_free_set(opl3->chset); return port; } return 0; }
static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) { snd_gus_port_t * p; snd_seq_port_callback_t callbacks; char name[32]; int result; p = &gus->gf1.seq_ports[idx]; p->chset = snd_midi_channel_alloc_set(16); if (p->chset == NULL) return -ENOMEM; p->chset->private_data = p; p->gus = gus; p->client = gus->gf1.seq_client; memset(&callbacks, 0, sizeof(callbacks)); callbacks.owner = THIS_MODULE; callbacks.use = snd_gus_synth_use; callbacks.unuse = snd_gus_synth_unuse; callbacks.event_input = snd_gus_synth_event_input; callbacks.private_free = snd_gus_synth_free_port; callbacks.private_data = p; sprintf(name, "%s port %i", gus->interwave ? "AMD InterWave" : "GF1", idx); p->chset->port = snd_seq_event_port_attach(gus->gf1.seq_client, &callbacks, SNDRV_SEQ_PORT_CAP_WRITE | SNDRV_SEQ_PORT_CAP_SUBS_WRITE, SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE | SNDRV_SEQ_PORT_TYPE_SYNTH, 16, 0, name); if (p->chset->port < 0) { result = p->chset->port; snd_gus_synth_free_port(p); return result; } p->port = p->chset->port; return 0; }
static int snd_opl3_oss_create_port(struct snd_opl3 * opl3) { struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; voices = (opl3->hardware < OPL3_HW_OPL3) ? MAX_OPL2_VOICES : MAX_OPL3_VOICES; opl3->oss_chset = snd_midi_channel_alloc_set(voices); if (opl3->oss_chset == NULL) return -ENOMEM; opl3->oss_chset->private_data = opl3; memset(&callbacks, 0, sizeof(callbacks)); callbacks.owner = THIS_MODULE; callbacks.event_input = snd_opl3_oss_event_input; callbacks.private_free = snd_opl3_oss_free_port; callbacks.private_data = opl3; opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; sprintf(name, "OPL%i OSS Port", opl_ver); opl3->oss_chset->client = opl3->seq_client; opl3->oss_chset->port = snd_seq_event_port_attach(opl3->seq_client, &callbacks, SNDRV_SEQ_PORT_CAP_WRITE, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | SNDRV_SEQ_PORT_TYPE_MIDI_GM | SNDRV_SEQ_PORT_TYPE_SYNTH, voices, voices, name); if (opl3->oss_chset->port < 0) { snd_midi_channel_free_set(opl3->oss_chset); return opl3->oss_chset->port; } return 0; }