Skip to content

Commit

Permalink
ALSA: firewire-lib: move MIDI trigger helper function to AM824 layer
Browse files Browse the repository at this point in the history
In IEC 61883-6, MIDI messages are transferred in MIDI conformant data
channel. Essentially, packet streaming layer is not responsible for MIDI
functionality.

This commit moves MIDI trigger helper function from the layer to AM824
layer. The rest of codes related to MIDI functionality will be moved in
later commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Sakamoto authored and Takashi Iwai committed Sep 29, 2015
1 parent f65be91 commit 03e2a67
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 46 deletions.
18 changes: 18 additions & 0 deletions sound/firewire/amdtp-am824.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
}
EXPORT_SYMBOL_GPL(amdtp_am824_add_pcm_hw_constraints);

/**
* amdtp_am824_midi_trigger - start/stop playback/capture with a MIDI device
* @s: the AMDTP stream
* @port: index of MIDI port
* @midi: the MIDI device to be started, or %NULL to stop the current device
*
* Call this function on a running isochronous stream to enable the actual
* transmission of MIDI data. This function should be called from the MIDI
* device's .trigger callback.
*/
void amdtp_am824_midi_trigger(struct amdtp_stream *s, unsigned int port,
struct snd_rawmidi_substream *midi)
{
if (port < s->midi_ports)
ACCESS_ONCE(s->midi[port]) = midi;
}
EXPORT_SYMBOL_GPL(amdtp_am824_midi_trigger);

/**
* amdtp_am824_init - initialize an AMDTP stream structure to handle AM824
* data block
Expand Down
4 changes: 4 additions & 0 deletions sound/firewire/amdtp-am824.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SOUND_FIREWIRE_AMDTP_AM824_H_INCLUDED

#include <sound/pcm.h>
#include <sound/rawmidi.h>

#include "amdtp-stream.h"

Expand All @@ -19,6 +20,9 @@ void amdtp_am824_set_midi_position(struct amdtp_stream *s,
int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
struct snd_pcm_runtime *runtime);

void amdtp_am824_midi_trigger(struct amdtp_stream *s, unsigned int port,
struct snd_rawmidi_substream *midi);

int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, enum cip_flags flags);
#endif
18 changes: 0 additions & 18 deletions sound/firewire/amdtp-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,6 @@ static inline void amdtp_stream_pcm_trigger(struct amdtp_stream *s,
ACCESS_ONCE(s->pcm) = pcm;
}

/**
* amdtp_stream_midi_trigger - start/stop playback/capture with a MIDI device
* @s: the AMDTP stream
* @port: index of MIDI port
* @midi: the MIDI device to be started, or %NULL to stop the current device
*
* Call this function on a running isochronous stream to enable the actual
* transmission of MIDI data. This function should be called from the MIDI
* device's .trigger callback.
*/
static inline void amdtp_stream_midi_trigger(struct amdtp_stream *s,
unsigned int port,
struct snd_rawmidi_substream *midi)
{
if (port < s->midi_ports)
ACCESS_ONCE(s->midi[port]) = midi;
}

static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
{
return sfc & 1;
Expand Down
16 changes: 8 additions & 8 deletions sound/firewire/bebob/bebob_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&bebob->lock, flags);

if (up)
amdtp_stream_midi_trigger(&bebob->tx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&bebob->tx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&bebob->tx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&bebob->tx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&bebob->lock, flags);
}
Expand All @@ -89,11 +89,11 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&bebob->lock, flags);

if (up)
amdtp_stream_midi_trigger(&bebob->rx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&bebob->rx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&bebob->rx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&bebob->rx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&bebob->lock, flags);
}
Expand Down
12 changes: 6 additions & 6 deletions sound/firewire/dice/dice-midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&dice->lock, flags);

if (up)
amdtp_stream_midi_trigger(&dice->tx_stream,
amdtp_am824_midi_trigger(&dice->tx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&dice->tx_stream,
amdtp_am824_midi_trigger(&dice->tx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&dice->lock, flags);
Expand All @@ -69,11 +69,11 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&dice->lock, flags);

if (up)
amdtp_stream_midi_trigger(&dice->rx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&dice->rx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&dice->rx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&dice->rx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&dice->lock, flags);
}
Expand Down
12 changes: 6 additions & 6 deletions sound/firewire/fireworks/fireworks_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&efw->lock, flags);

if (up)
amdtp_stream_midi_trigger(&efw->tx_stream,
amdtp_am824_midi_trigger(&efw->tx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&efw->tx_stream,
amdtp_am824_midi_trigger(&efw->tx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&efw->lock, flags);
Expand All @@ -90,11 +90,11 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&efw->lock, flags);

if (up)
amdtp_stream_midi_trigger(&efw->rx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&efw->rx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&efw->rx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&efw->rx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&efw->lock, flags);
}
Expand Down
16 changes: 8 additions & 8 deletions sound/firewire/oxfw/oxfw-midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&oxfw->lock, flags);

if (up)
amdtp_stream_midi_trigger(&oxfw->tx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&oxfw->tx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&oxfw->tx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&oxfw->tx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&oxfw->lock, flags);
}
Expand All @@ -107,11 +107,11 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
spin_lock_irqsave(&oxfw->lock, flags);

if (up)
amdtp_stream_midi_trigger(&oxfw->rx_stream,
substrm->number, substrm);
amdtp_am824_midi_trigger(&oxfw->rx_stream,
substrm->number, substrm);
else
amdtp_stream_midi_trigger(&oxfw->rx_stream,
substrm->number, NULL);
amdtp_am824_midi_trigger(&oxfw->rx_stream,
substrm->number, NULL);

spin_unlock_irqrestore(&oxfw->lock, flags);
}
Expand Down

0 comments on commit 03e2a67

Please sign in to comment.