[alsa-devel] [PATCH 24/25] ALSA: firewire-tascam: add MIDI functionality

Takashi Iwai tiwai at suse.de
Mon Aug 24 22:59:02 CEST 2015


On Sat, 22 Aug 2015 11:19:40 +0200,
Takashi Sakamoto wrote:
> 
> This commit adds MIDI functionality to transfer/receive MIDI messages.
> 
> Console models supports virtual MIDI ports additional to physical MIDI
> ports. Once physical controls are assigned to the virtual MIDI ports,
> userspace applications can receive/transmit MIDI messages from/to the
> MIDI ports. Additionally, without assignment, physical controls can
> transmit control events in isochronous packets. This messages are
> supported in later commit.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
> ---
>  sound/firewire/tascam/Makefile      |   3 +-
>  sound/firewire/tascam/tascam-midi.c | 162 ++++++++++++++++++++++++++++++++++++
>  sound/firewire/tascam/tascam.c      |   4 +
>  sound/firewire/tascam/tascam.h      |   3 +
>  4 files changed, 171 insertions(+), 1 deletion(-)
>  create mode 100644 sound/firewire/tascam/tascam-midi.c
> 
> diff --git a/sound/firewire/tascam/Makefile b/sound/firewire/tascam/Makefile
> index 2c3d101..905fdc1 100644
> --- a/sound/firewire/tascam/Makefile
> +++ b/sound/firewire/tascam/Makefile
> @@ -1,3 +1,4 @@
>  snd-firewire-tascam-objs := tascam-proc.o amdtp-tascam.o tascam-stream.o \
> -			    tascam-pcm.o tascam-transaction.o tascam.o
> +			    tascam-pcm.o tascam-transaction.o tascam-midi.o \
> +			    tascam.o
>  obj-$(CONFIG_SND_FIREWIRE_TASCAM) += snd-firewire-tascam.o
> diff --git a/sound/firewire/tascam/tascam-midi.c b/sound/firewire/tascam/tascam-midi.c
> new file mode 100644
> index 0000000..f0344b3
> --- /dev/null
> +++ b/sound/firewire/tascam/tascam-midi.c
> @@ -0,0 +1,162 @@
> +/*
> + * tascam-midi.c - a part of driver for TASCAM FireWire series
> + *
> + * Copyright (c) 2015 Takashi Sakamoto
> + *
> + * Licensed under the terms of the GNU General Public License, version 2.
> + */
> +
> +#include "tascam.h"
> +
> +static int midi_capture_open(struct snd_rawmidi_substream *substream)
> +{
> +	/* TODO: pick up hardware control messages as MIDI? */
> +	if (substream->pstr->substream_count == substream->number)
> +		return -1;

No error code?

> +
> +	return 0;
> +}
> +
> +static int midi_playback_open(struct snd_rawmidi_substream *substream)
> +{
> +	struct snd_tscm *tscm = substream->rmidi->private_data;
> +
> +	/* Initialize internal status. */
> +	tscm->running_status[substream->number] = 0;
> +	tscm->on_sysex[substream->number] = 0;
> +	return 0;
> +}
> +
> +static int midi_capture_close(struct snd_rawmidi_substream *substream)
> +{
> +	/* TODO: pick up hardware control messages as MIDI? */
> +	if (substream->pstr->substream_count == substream->number)
> +		return -1;

Ditto.

> +
> +	return 0;
> +}
> +
> +static int midi_playback_close(struct snd_rawmidi_substream *substream)
> +{
> +	struct snd_tscm *tscm = substream->rmidi->private_data;
> +
> +	snd_fw_async_midi_port_finish(&tscm->out_ports[substream->number]);
> +
> +	return 0;
> +}
> +
> +static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
> +{
> +	struct snd_tscm *tscm = substrm->rmidi->private_data;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&tscm->lock, flags);
> +
> +	/* TODO: pick up hardware control messages as MIDI? */
> +	if (substrm->pstr->substream_count == substrm->number) {
> +		return;

Missing spin unlock.

> +	} else {
> +		if (up)
> +			tscm->tx_midi_substreams[substrm->number] = substrm;
> +		else
> +			tscm->tx_midi_substreams[substrm->number] = NULL;
> +	}
> +
> +	spin_unlock_irqrestore(&tscm->lock, flags);
> +}
> +
(snip)
> diff --git a/sound/firewire/tascam/tascam.h b/sound/firewire/tascam/tascam.h
> index 920bf30..0c0b753 100644
> --- a/sound/firewire/tascam/tascam.h
> +++ b/sound/firewire/tascam/tascam.h
> @@ -46,6 +46,7 @@ struct snd_tscm {
>  	struct fw_unit *unit;
>  
>  	struct mutex mutex;
> +	spinlock_t lock;

Where is it initialized?


Takashi


More information about the Alsa-devel mailing list