提交 0c3f15f3 编写于 作者: T Takashi Sakamoto 提交者: Takashi Iwai

ALSA: firewire-digi00x: allow user space applications to read/write MIDI messages for all ports

At a commit c5fcee03 ("ALSA: firewire-digi00x: add MIDI operations for
MIDI control port"), I described that MIDI messages for control surface is
transferred by a different way from the messages for physical ports.
However, this is wrong. MIDI messages to/from all of MIDI ports are
transferred by isochronous packets.

This commit removes codes to transfer MIDI messages via asynchronous
transaction, from MIDI handling layer.
Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 8820a4cf
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "digi00x.h" #include "digi00x.h"
static int midi_phys_open(struct snd_rawmidi_substream *substream) static int midi_open(struct snd_rawmidi_substream *substream)
{ {
struct snd_dg00x *dg00x = substream->rmidi->private_data; struct snd_dg00x *dg00x = substream->rmidi->private_data;
int err; int err;
...@@ -27,7 +27,7 @@ static int midi_phys_open(struct snd_rawmidi_substream *substream) ...@@ -27,7 +27,7 @@ static int midi_phys_open(struct snd_rawmidi_substream *substream)
return err; return err;
} }
static int midi_phys_close(struct snd_rawmidi_substream *substream) static int midi_close(struct snd_rawmidi_substream *substream)
{ {
struct snd_dg00x *dg00x = substream->rmidi->private_data; struct snd_dg00x *dg00x = substream->rmidi->private_data;
...@@ -40,180 +40,130 @@ static int midi_phys_close(struct snd_rawmidi_substream *substream) ...@@ -40,180 +40,130 @@ static int midi_phys_close(struct snd_rawmidi_substream *substream)
return 0; return 0;
} }
static void midi_phys_capture_trigger(struct snd_rawmidi_substream *substream, static void midi_capture_trigger(struct snd_rawmidi_substream *substream,
int up) int up)
{ {
struct snd_dg00x *dg00x = substream->rmidi->private_data; struct snd_dg00x *dg00x = substream->rmidi->private_data;
unsigned int port;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&dg00x->lock, flags); if (substream->rmidi->device == 0)
port = substream->number;
if (up)
amdtp_dot_midi_trigger(&dg00x->tx_stream, substream->number,
substream);
else else
amdtp_dot_midi_trigger(&dg00x->tx_stream, substream->number, port = 2;
NULL);
spin_unlock_irqrestore(&dg00x->lock, flags);
}
static void midi_phys_playback_trigger(struct snd_rawmidi_substream *substream,
int up)
{
struct snd_dg00x *dg00x = substream->rmidi->private_data;
unsigned long flags;
spin_lock_irqsave(&dg00x->lock, flags); spin_lock_irqsave(&dg00x->lock, flags);
if (up) if (up)
amdtp_dot_midi_trigger(&dg00x->rx_stream, substream->number, amdtp_dot_midi_trigger(&dg00x->tx_stream, port, substream);
substream);
else else
amdtp_dot_midi_trigger(&dg00x->rx_stream, substream->number, amdtp_dot_midi_trigger(&dg00x->tx_stream, port, NULL);
NULL);
spin_unlock_irqrestore(&dg00x->lock, flags); spin_unlock_irqrestore(&dg00x->lock, flags);
} }
static int midi_ctl_open(struct snd_rawmidi_substream *substream) static void midi_playback_trigger(struct snd_rawmidi_substream *substream,
{ int up)
/* Do nothing. */
return 0;
}
static int midi_ctl_capture_close(struct snd_rawmidi_substream *substream)
{
/* Do nothing. */
return 0;
}
static int midi_ctl_playback_close(struct snd_rawmidi_substream *substream)
{
struct snd_dg00x *dg00x = substream->rmidi->private_data;
snd_fw_async_midi_port_finish(&dg00x->out_control);
return 0;
}
static void midi_ctl_capture_trigger(struct snd_rawmidi_substream *substream,
int up)
{ {
struct snd_dg00x *dg00x = substream->rmidi->private_data; struct snd_dg00x *dg00x = substream->rmidi->private_data;
unsigned int port;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&dg00x->lock, flags); if (substream->rmidi->device == 0)
port = substream->number;
if (up)
dg00x->in_control = substream;
else else
dg00x->in_control = NULL; port = 2;
spin_unlock_irqrestore(&dg00x->lock, flags);
}
static void midi_ctl_playback_trigger(struct snd_rawmidi_substream *substream,
int up)
{
struct snd_dg00x *dg00x = substream->rmidi->private_data;
unsigned long flags;
spin_lock_irqsave(&dg00x->lock, flags); spin_lock_irqsave(&dg00x->lock, flags);
if (up) if (up)
snd_fw_async_midi_port_run(&dg00x->out_control, substream); amdtp_dot_midi_trigger(&dg00x->rx_stream, port, substream);
else
amdtp_dot_midi_trigger(&dg00x->rx_stream, port, NULL);
spin_unlock_irqrestore(&dg00x->lock, flags); spin_unlock_irqrestore(&dg00x->lock, flags);
} }
static void set_midi_substream_names(struct snd_dg00x *dg00x, static void set_substream_names(struct snd_dg00x *dg00x,
struct snd_rawmidi_str *str, struct snd_rawmidi *rmidi, bool is_console)
bool is_ctl)
{ {
struct snd_rawmidi_substream *subs; struct snd_rawmidi_substream *subs;
struct snd_rawmidi_str *str;
list_for_each_entry(subs, &str->substreams, list) { int i;
if (!is_ctl)
snprintf(subs->name, sizeof(subs->name), for (i = 0; i < 2; ++i) {
"%s MIDI %d", str = &rmidi->streams[i];
dg00x->card->shortname, subs->number + 1);
else list_for_each_entry(subs, &str->substreams, list) {
/* This port is for asynchronous transaction. */ if (!is_console) {
snprintf(subs->name, sizeof(subs->name), snprintf(subs->name, sizeof(subs->name),
"%s control", "%s MIDI %d",
dg00x->card->shortname); dg00x->card->shortname,
subs->number + 1);
} else {
snprintf(subs->name, sizeof(subs->name),
"%s control",
dg00x->card->shortname);
}
}
} }
} }
int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x) static int add_substream_pair(struct snd_dg00x *dg00x, unsigned int out_ports,
unsigned int in_ports, bool is_console)
{ {
static const struct snd_rawmidi_ops phys_capture_ops = { static const struct snd_rawmidi_ops capture_ops = {
.open = midi_phys_open, .open = midi_open,
.close = midi_phys_close, .close = midi_close,
.trigger = midi_phys_capture_trigger, .trigger = midi_capture_trigger,
};
static const struct snd_rawmidi_ops phys_playback_ops = {
.open = midi_phys_open,
.close = midi_phys_close,
.trigger = midi_phys_playback_trigger,
}; };
static const struct snd_rawmidi_ops ctl_capture_ops = { static const struct snd_rawmidi_ops playback_ops = {
.open = midi_ctl_open, .open = midi_open,
.close = midi_ctl_capture_close, .close = midi_close,
.trigger = midi_ctl_capture_trigger, .trigger = midi_playback_trigger,
}; };
static const struct snd_rawmidi_ops ctl_playback_ops = { const char *label;
.open = midi_ctl_open, struct snd_rawmidi *rmidi;
.close = midi_ctl_playback_close,
.trigger = midi_ctl_playback_trigger,
};
struct snd_rawmidi *rmidi[2];
struct snd_rawmidi_str *str;
unsigned int i;
int err; int err;
/* Add physical midi ports. */ /* Add physical midi ports. */
err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, 0, err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, is_console,
DOT_MIDI_OUT_PORTS, DOT_MIDI_IN_PORTS, &rmidi[0]); out_ports, in_ports, &rmidi);
if (err < 0) if (err < 0)
return err; return err;
rmidi->private_data = dg00x;
snprintf(rmidi[0]->name, sizeof(rmidi[0]->name), if (!is_console)
"%s MIDI", dg00x->card->shortname); label = "%s control";
else
snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_INPUT, label = "%s MIDI";
&phys_capture_ops); snprintf(rmidi->name, sizeof(rmidi->name), label,
snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_OUTPUT, dg00x->card->shortname);
&phys_playback_ops);
/* Add a pair of control midi ports. */ snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &playback_ops);
err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, 1, snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &capture_ops);
1, 1, &rmidi[1]);
if (err < 0)
return err;
snprintf(rmidi[1]->name, sizeof(rmidi[1]->name), rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT |
"%s control", dg00x->card->shortname); SNDRV_RAWMIDI_INFO_OUTPUT |
SNDRV_RAWMIDI_INFO_DUPLEX;
snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_INPUT, set_substream_names(dg00x, rmidi, is_console);
&ctl_capture_ops);
snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_OUTPUT,
&ctl_playback_ops);
for (i = 0; i < ARRAY_SIZE(rmidi); i++) { return 0;
rmidi[i]->private_data = dg00x; }
rmidi[i]->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x)
str = &rmidi[i]->streams[SNDRV_RAWMIDI_STREAM_INPUT]; {
set_midi_substream_names(dg00x, str, i); int err;
rmidi[i]->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; /* Add physical midi ports. */
str = &rmidi[i]->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]; err = add_substream_pair(dg00x, DOT_MIDI_OUT_PORTS, DOT_MIDI_IN_PORTS,
set_midi_substream_names(dg00x, str, i); false);
if (err < 0)
return err;
rmidi[i]->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX; if (dg00x->is_console)
} err = add_substream_pair(dg00x, 1, 1, true);
return 0; return err;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册