summaryrefslogtreecommitdiff
path: root/sound/firewire/digi00x/digi00x-midi.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 11:58:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 11:58:59 -0700
commit221656e7c4ce342b99c31eca96c1cbb6d1dce45f (patch)
tree1af3655475361f3ec75d8e26bc8d5f4bad8a87b0 /sound/firewire/digi00x/digi00x-midi.c
parent2f34c1231bfc9f2550f934acb268ac7315fb3837 (diff)
parenta5c3b32a1146e44f6b38fdfdfffc27842953420c (diff)
Merge tag 'sound-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai: "It was a relatively calm development cycle, and no scaring changes are seen in both core and driver sides. Here are some highlights: ASoC: - A new API for hooking up jacks more generically and easily - Card longname is set based on DMI for a unique UCM profile - Lots of Intel driver fixes: Atom, Broxton, Skylake and newer chips - New drivers for Cirrus CS35L35, DIO DIO2125, Everest ES7132, HiSilicon hi6210, Maxim MAX98927, MT2701 systems with WM8960, Nuvoton NAU8824, Odroid systems, ST STM32 SAI controllers and x86 systems with DA7213 HD-audio: - Many new quirks to support headset for various devices (mostly ASUS ones) as usual - Support for dual codecs on some Gigabyte mobos and Lenovo laptop - Improvement on PCM position reporting for Skylake and newer FireWire: - New drivers for MOTU and RME Fireface series - Updates for Digidesign Digi00x and TASCAM series - Support for tracepoints Others: - USB-audio: improved support for quirk_alias option - Cleanups, constification allover the places" * tag 'sound-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (299 commits) ASoC: codec: wm8960: Relax bit clock computation when using PLL ASoC: codec: wm9860: avoid maybe-uninitialized warning ASoC: nau8824: leave Class D gain at chip default ASoC: nau8824: rename controls to match DAPM controls ASoC: Intel: Skylake: Return negative error code ASoC: Intel: Skylake: Fix unused variable warning ASoC: Intel: Skylake: fix uninitialized pointer use ASoC: sti: Fix error handling if of_clk_get() fails ASoC: cs4271: configure reset GPIO as output ASoC: dwc: Disallow building designware_pcm as a module ALSA: ali5451: fix spelling mistake in "ali_capture_preapre" ASoC: stm32: add SAI driver ASoC: stm32: add bindings for SAI ASoC: Intel: Skylake: Add loadable module support on KBL platform ASoC: Intel: Skylake: Modify load_lib_ipc arguments for a nowait version ASoC: Intel: Skylake: Register dsp_fw_ops for kabylake ASoC: Intel: Skylake: Modify arguments to reuse module transfer function ASoC: Intel: Skylake: Commonize library load ASoC: Intel: Skylake: Move sst common initialization to a helper function ASoC: nau8824: new driver ...
Diffstat (limited to 'sound/firewire/digi00x/digi00x-midi.c')
-rw-r--r--sound/firewire/digi00x/digi00x-midi.c208
1 files changed, 79 insertions, 129 deletions
diff --git a/sound/firewire/digi00x/digi00x-midi.c b/sound/firewire/digi00x/digi00x-midi.c
index 915d2a21223e..7ab3d0810f6b 100644
--- a/sound/firewire/digi00x/digi00x-midi.c
+++ b/sound/firewire/digi00x/digi00x-midi.c
@@ -8,7 +8,7 @@
#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;
int err;
@@ -27,7 +27,7 @@ static int midi_phys_open(struct snd_rawmidi_substream *substream)
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;
@@ -40,180 +40,130 @@ static int midi_phys_close(struct snd_rawmidi_substream *substream)
return 0;
}
-static void midi_phys_capture_trigger(struct snd_rawmidi_substream *substream,
- int up)
+static void midi_capture_trigger(struct snd_rawmidi_substream *substream,
+ int up)
{
struct snd_dg00x *dg00x = substream->rmidi->private_data;
+ unsigned int port;
unsigned long flags;
- spin_lock_irqsave(&dg00x->lock, flags);
-
- if (up)
- amdtp_dot_midi_trigger(&dg00x->tx_stream, substream->number,
- substream);
+ if (substream->rmidi->device == 0)
+ port = substream->number;
else
- amdtp_dot_midi_trigger(&dg00x->tx_stream, substream->number,
- 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;
+ port = 2;
spin_lock_irqsave(&dg00x->lock, flags);
if (up)
- amdtp_dot_midi_trigger(&dg00x->rx_stream, substream->number,
- substream);
+ amdtp_dot_midi_trigger(&dg00x->tx_stream, port, substream);
else
- amdtp_dot_midi_trigger(&dg00x->rx_stream, substream->number,
- NULL);
+ amdtp_dot_midi_trigger(&dg00x->tx_stream, port, NULL);
spin_unlock_irqrestore(&dg00x->lock, flags);
}
-static int midi_ctl_open(struct snd_rawmidi_substream *substream)
-{
- /* 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)
+static void midi_playback_trigger(struct snd_rawmidi_substream *substream,
+ int up)
{
struct snd_dg00x *dg00x = substream->rmidi->private_data;
+ unsigned int port;
unsigned long flags;
- spin_lock_irqsave(&dg00x->lock, flags);
-
- if (up)
- dg00x->in_control = substream;
+ if (substream->rmidi->device == 0)
+ port = substream->number;
else
- dg00x->in_control = NULL;
-
- 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;
+ port = 2;
spin_lock_irqsave(&dg00x->lock, flags);
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);
}
-static void set_midi_substream_names(struct snd_dg00x *dg00x,
- struct snd_rawmidi_str *str,
- bool is_ctl)
+static void set_substream_names(struct snd_dg00x *dg00x,
+ struct snd_rawmidi *rmidi, bool is_console)
{
struct snd_rawmidi_substream *subs;
-
- list_for_each_entry(subs, &str->substreams, list) {
- if (!is_ctl)
- snprintf(subs->name, sizeof(subs->name),
- "%s MIDI %d",
- dg00x->card->shortname, subs->number + 1);
- else
- /* This port is for asynchronous transaction. */
- snprintf(subs->name, sizeof(subs->name),
- "%s control",
- dg00x->card->shortname);
+ struct snd_rawmidi_str *str;
+ int i;
+
+ for (i = 0; i < 2; ++i) {
+ str = &rmidi->streams[i];
+
+ list_for_each_entry(subs, &str->substreams, list) {
+ if (!is_console) {
+ snprintf(subs->name, sizeof(subs->name),
+ "%s MIDI %d",
+ 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 = {
- .open = midi_phys_open,
- .close = midi_phys_close,
- .trigger = midi_phys_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 capture_ops = {
+ .open = midi_open,
+ .close = midi_close,
+ .trigger = midi_capture_trigger,
};
- static const struct snd_rawmidi_ops ctl_capture_ops = {
- .open = midi_ctl_open,
- .close = midi_ctl_capture_close,
- .trigger = midi_ctl_capture_trigger,
+ static const struct snd_rawmidi_ops playback_ops = {
+ .open = midi_open,
+ .close = midi_close,
+ .trigger = midi_playback_trigger,
};
- static const struct snd_rawmidi_ops ctl_playback_ops = {
- .open = midi_ctl_open,
- .close = midi_ctl_playback_close,
- .trigger = midi_ctl_playback_trigger,
- };
- struct snd_rawmidi *rmidi[2];
- struct snd_rawmidi_str *str;
- unsigned int i;
+ const char *label;
+ struct snd_rawmidi *rmidi;
int err;
/* Add physical midi ports. */
- err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, 0,
- DOT_MIDI_OUT_PORTS, DOT_MIDI_IN_PORTS, &rmidi[0]);
+ err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, is_console,
+ out_ports, in_ports, &rmidi);
if (err < 0)
return err;
+ rmidi->private_data = dg00x;
- snprintf(rmidi[0]->name, sizeof(rmidi[0]->name),
- "%s MIDI", dg00x->card->shortname);
-
- snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_INPUT,
- &phys_capture_ops);
- snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_OUTPUT,
- &phys_playback_ops);
+ if (!is_console)
+ label = "%s control";
+ else
+ label = "%s MIDI";
+ snprintf(rmidi->name, sizeof(rmidi->name), label,
+ dg00x->card->shortname);
- /* Add a pair of control midi ports. */
- err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, 1,
- 1, 1, &rmidi[1]);
- if (err < 0)
- return err;
+ snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &playback_ops);
+ snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &capture_ops);
- snprintf(rmidi[1]->name, sizeof(rmidi[1]->name),
- "%s control", dg00x->card->shortname);
+ rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT |
+ SNDRV_RAWMIDI_INFO_OUTPUT |
+ SNDRV_RAWMIDI_INFO_DUPLEX;
- snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_INPUT,
- &ctl_capture_ops);
- snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_OUTPUT,
- &ctl_playback_ops);
+ set_substream_names(dg00x, rmidi, is_console);
- for (i = 0; i < ARRAY_SIZE(rmidi); i++) {
- rmidi[i]->private_data = dg00x;
+ return 0;
+}
- rmidi[i]->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
- str = &rmidi[i]->streams[SNDRV_RAWMIDI_STREAM_INPUT];
- set_midi_substream_names(dg00x, str, i);
+int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x)
+{
+ int err;
- rmidi[i]->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
- str = &rmidi[i]->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];
- set_midi_substream_names(dg00x, str, i);
+ /* Add physical midi ports. */
+ err = add_substream_pair(dg00x, DOT_MIDI_OUT_PORTS, DOT_MIDI_IN_PORTS,
+ 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;
}