/* Attach a device driver that wants to receive events from the sequencer. Returns the new port number on success. A driver that wants to receive the events converted to midi, will use snd_seq_midisynth_register_port().  */
int snd_seq_event_port_attach(int client, struct snd_seq_port_callback *pcbp, int cap, int type, int midi_channels, int midi_voices, char *portname)
/* Attach a device driver that wants to receive events from the sequencer. Returns the new port number on success. A driver that wants to receive the events converted to midi, will use snd_seq_midisynth_register_port().  */
int snd_seq_event_port_attach(int client, struct snd_seq_port_callback *pcbp, int cap, int type, int midi_channels, int midi_voices, char *portname)
{
	struct snd_seq_port_info portinfo;
	int  ret;
	memset(&portinfo, 0, sizeof(portinfo));
	portinfo.addr.client = client;
	strlcpy(portinfo.name, portname ? portname : "Unamed port",
		sizeof(portinfo.name));
	portinfo.capability = cap;
	portinfo.type = type;
	portinfo.kernel = pcbp;
	portinfo.midi_channels = midi_channels;
	portinfo.midi_voices = midi_voices;
	ret = snd_seq_kernel_client_ctl(client,
					SNDRV_SEQ_IOCTL_CREATE_PORT,
					&portinfo);
	if (ret >= 0)
		ret = portinfo.addr.port;
	return ret;
}