示例#1
0
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;
}
示例#2
0
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;
}
示例#3
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;
}