2019-05-30 07:57:59 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-12-08 23:10:39 +08:00
|
|
|
/*
|
|
|
|
* dice_midi.c - a part of driver for Dice based devices
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Takashi Sakamoto
|
|
|
|
*/
|
|
|
|
#include "dice.h"
|
|
|
|
|
|
|
|
static int midi_open(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->rmidi->private_data;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_dice_stream_lock_try(dice);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
|
2019-06-11 21:21:16 +08:00
|
|
|
err = snd_dice_stream_reserve_duplex(dice, 0);
|
|
|
|
if (err >= 0) {
|
|
|
|
++dice->substreams_counter;
|
|
|
|
err = snd_dice_stream_start_duplex(dice);
|
2019-07-07 13:20:09 +08:00
|
|
|
if (err < 0)
|
|
|
|
--dice->substreams_counter;
|
2019-06-11 21:21:16 +08:00
|
|
|
}
|
2014-12-08 23:10:39 +08:00
|
|
|
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
|
|
|
if (err < 0)
|
|
|
|
snd_dice_stream_lock_release(dice);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int midi_close(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->rmidi->private_data;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
|
2019-06-11 21:21:16 +08:00
|
|
|
--dice->substreams_counter;
|
2014-12-08 23:10:39 +08:00
|
|
|
snd_dice_stream_stop_duplex(dice);
|
|
|
|
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
|
|
|
snd_dice_stream_lock_release(dice);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substrm->rmidi->private_data;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dice->lock, flags);
|
|
|
|
|
|
|
|
if (up)
|
ALSA: dice: have two sets of isochronous resources/streams
Currently ALSA dice driver handles a pair of isochronous resources for
IEC 61883-1/6 packet streaming. While, according to some documents about
ASICs named as 'Dice', several isochronous streams are available.
Here, I start to describe ASICs produced under 'Dice' name.
* Dice II (designed by wavefront semiconductor, including TCAT's IP)
* STD (with limited functionality of DTCP)
* CP (with full functionality of DTCP)
* TCD2210/2210-E (so-called 'Dice Mini')
* TCD2220/2220-E (so-called 'Dice Jr.')
* TCD3070-CH (so-called 'Dice III')
Some documents are public and we can see hardware design of them. We can
find some articles about hardware internal register definitions
(not registers exported to IEEE 1394 bus).
* DICE II User Guide
* http://www.tctechnologies.tc/archive/downloads/dice_ii_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 6.1: AVS Audio Receiver Memory Map
* ARX1-ARX4
* 6.2 AVS Audio Transmitters
* Table 6.2: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* TCD22xx User Guide
* http://www.tctechnologies.tc/downloads/tcd22xx_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 66: AVS Audio Receiver Memory Map
* ARX1, ARX2
* 6/2 AVS Audio Transmitters
* Table 67: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* DICE III
* http://www.tctechnologies.tc/downloads/TCD3070-CH.pdf
* Dual stream 63 channel transmitter/receiver
For Dice II and TCD22xx series, maximum 16 data channels are transferred in
an AMDTP packet, while for Dice III, maximum 32 data channels are
transferred.
According to the design of the series of these ASICs, this commit allows
this driver to handle additional set of isochronous resources. For
practical reason, two pair of isochronous resources are added. As of this
commit, this driver still use a pair of the first isochronous resources.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-07 21:35:42 +08:00
|
|
|
amdtp_am824_midi_trigger(&dice->tx_stream[0],
|
2014-12-08 23:10:39 +08:00
|
|
|
substrm->number, substrm);
|
|
|
|
else
|
ALSA: dice: have two sets of isochronous resources/streams
Currently ALSA dice driver handles a pair of isochronous resources for
IEC 61883-1/6 packet streaming. While, according to some documents about
ASICs named as 'Dice', several isochronous streams are available.
Here, I start to describe ASICs produced under 'Dice' name.
* Dice II (designed by wavefront semiconductor, including TCAT's IP)
* STD (with limited functionality of DTCP)
* CP (with full functionality of DTCP)
* TCD2210/2210-E (so-called 'Dice Mini')
* TCD2220/2220-E (so-called 'Dice Jr.')
* TCD3070-CH (so-called 'Dice III')
Some documents are public and we can see hardware design of them. We can
find some articles about hardware internal register definitions
(not registers exported to IEEE 1394 bus).
* DICE II User Guide
* http://www.tctechnologies.tc/archive/downloads/dice_ii_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 6.1: AVS Audio Receiver Memory Map
* ARX1-ARX4
* 6.2 AVS Audio Transmitters
* Table 6.2: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* TCD22xx User Guide
* http://www.tctechnologies.tc/downloads/tcd22xx_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 66: AVS Audio Receiver Memory Map
* ARX1, ARX2
* 6/2 AVS Audio Transmitters
* Table 67: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* DICE III
* http://www.tctechnologies.tc/downloads/TCD3070-CH.pdf
* Dual stream 63 channel transmitter/receiver
For Dice II and TCD22xx series, maximum 16 data channels are transferred in
an AMDTP packet, while for Dice III, maximum 32 data channels are
transferred.
According to the design of the series of these ASICs, this commit allows
this driver to handle additional set of isochronous resources. For
practical reason, two pair of isochronous resources are added. As of this
commit, this driver still use a pair of the first isochronous resources.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-07 21:35:42 +08:00
|
|
|
amdtp_am824_midi_trigger(&dice->tx_stream[0],
|
2014-12-08 23:10:39 +08:00
|
|
|
substrm->number, NULL);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dice->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substrm->rmidi->private_data;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dice->lock, flags);
|
|
|
|
|
|
|
|
if (up)
|
ALSA: dice: have two sets of isochronous resources/streams
Currently ALSA dice driver handles a pair of isochronous resources for
IEC 61883-1/6 packet streaming. While, according to some documents about
ASICs named as 'Dice', several isochronous streams are available.
Here, I start to describe ASICs produced under 'Dice' name.
* Dice II (designed by wavefront semiconductor, including TCAT's IP)
* STD (with limited functionality of DTCP)
* CP (with full functionality of DTCP)
* TCD2210/2210-E (so-called 'Dice Mini')
* TCD2220/2220-E (so-called 'Dice Jr.')
* TCD3070-CH (so-called 'Dice III')
Some documents are public and we can see hardware design of them. We can
find some articles about hardware internal register definitions
(not registers exported to IEEE 1394 bus).
* DICE II User Guide
* http://www.tctechnologies.tc/archive/downloads/dice_ii_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 6.1: AVS Audio Receiver Memory Map
* ARX1-ARX4
* 6.2 AVS Audio Transmitters
* Table 6.2: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* TCD22xx User Guide
* http://www.tctechnologies.tc/downloads/tcd22xx_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 66: AVS Audio Receiver Memory Map
* ARX1, ARX2
* 6/2 AVS Audio Transmitters
* Table 67: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* DICE III
* http://www.tctechnologies.tc/downloads/TCD3070-CH.pdf
* Dual stream 63 channel transmitter/receiver
For Dice II and TCD22xx series, maximum 16 data channels are transferred in
an AMDTP packet, while for Dice III, maximum 32 data channels are
transferred.
According to the design of the series of these ASICs, this commit allows
this driver to handle additional set of isochronous resources. For
practical reason, two pair of isochronous resources are added. As of this
commit, this driver still use a pair of the first isochronous resources.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-07 21:35:42 +08:00
|
|
|
amdtp_am824_midi_trigger(&dice->rx_stream[0],
|
2015-09-19 10:21:59 +08:00
|
|
|
substrm->number, substrm);
|
2014-12-08 23:10:39 +08:00
|
|
|
else
|
ALSA: dice: have two sets of isochronous resources/streams
Currently ALSA dice driver handles a pair of isochronous resources for
IEC 61883-1/6 packet streaming. While, according to some documents about
ASICs named as 'Dice', several isochronous streams are available.
Here, I start to describe ASICs produced under 'Dice' name.
* Dice II (designed by wavefront semiconductor, including TCAT's IP)
* STD (with limited functionality of DTCP)
* CP (with full functionality of DTCP)
* TCD2210/2210-E (so-called 'Dice Mini')
* TCD2220/2220-E (so-called 'Dice Jr.')
* TCD3070-CH (so-called 'Dice III')
Some documents are public and we can see hardware design of them. We can
find some articles about hardware internal register definitions
(not registers exported to IEEE 1394 bus).
* DICE II User Guide
* http://www.tctechnologies.tc/archive/downloads/dice_ii_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 6.1: AVS Audio Receiver Memory Map
* ARX1-ARX4
* 6.2 AVS Audio Transmitters
* Table 6.2: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* TCD22xx User Guide
* http://www.tctechnologies.tc/downloads/tcd22xx_user_guide.pdf
* 6.1 AVS Audio Receivers
* Table 66: AVS Audio Receiver Memory Map
* ARX1, ARX2
* 6/2 AVS Audio Transmitters
* Table 67: AVS Audio Transmitter Memory Map
* ATX1, ATX2
* DICE III
* http://www.tctechnologies.tc/downloads/TCD3070-CH.pdf
* Dual stream 63 channel transmitter/receiver
For Dice II and TCD22xx series, maximum 16 data channels are transferred in
an AMDTP packet, while for Dice III, maximum 32 data channels are
transferred.
According to the design of the series of these ASICs, this commit allows
this driver to handle additional set of isochronous resources. For
practical reason, two pair of isochronous resources are added. As of this
commit, this driver still use a pair of the first isochronous resources.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-07 21:35:42 +08:00
|
|
|
amdtp_am824_midi_trigger(&dice->rx_stream[0],
|
2015-09-19 10:21:59 +08:00
|
|
|
substrm->number, NULL);
|
2014-12-08 23:10:39 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dice->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_midi_substream_names(struct snd_dice *dice,
|
|
|
|
struct snd_rawmidi_str *str)
|
|
|
|
{
|
|
|
|
struct snd_rawmidi_substream *subs;
|
|
|
|
|
|
|
|
list_for_each_entry(subs, &str->substreams, list) {
|
|
|
|
snprintf(subs->name, sizeof(subs->name),
|
|
|
|
"%s MIDI %d", dice->card->shortname, subs->number + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int snd_dice_create_midi(struct snd_dice *dice)
|
|
|
|
{
|
2017-01-06 00:29:54 +08:00
|
|
|
static const struct snd_rawmidi_ops capture_ops = {
|
2017-01-05 20:48:10 +08:00
|
|
|
.open = midi_open,
|
|
|
|
.close = midi_close,
|
|
|
|
.trigger = midi_capture_trigger,
|
|
|
|
};
|
2017-01-06 00:29:54 +08:00
|
|
|
static const struct snd_rawmidi_ops playback_ops = {
|
2017-01-05 20:48:10 +08:00
|
|
|
.open = midi_open,
|
|
|
|
.close = midi_close,
|
|
|
|
.trigger = midi_playback_trigger,
|
|
|
|
};
|
2014-12-08 23:10:39 +08:00
|
|
|
struct snd_rawmidi *rmidi;
|
|
|
|
struct snd_rawmidi_str *str;
|
2016-02-08 21:54:17 +08:00
|
|
|
unsigned int midi_in_ports, midi_out_ports;
|
2018-05-02 18:16:49 +08:00
|
|
|
int i;
|
2014-12-08 23:10:39 +08:00
|
|
|
int err;
|
|
|
|
|
2018-05-02 18:16:49 +08:00
|
|
|
midi_in_ports = 0;
|
|
|
|
midi_out_ports = 0;
|
|
|
|
for (i = 0; i < MAX_STREAMS; ++i) {
|
|
|
|
midi_in_ports = max(midi_in_ports, dice->tx_midi_ports[i]);
|
|
|
|
midi_out_ports = max(midi_out_ports, dice->rx_midi_ports[i]);
|
|
|
|
}
|
2014-12-08 23:10:39 +08:00
|
|
|
|
|
|
|
if (midi_in_ports + midi_out_ports == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* create midi ports */
|
|
|
|
err = snd_rawmidi_new(dice->card, dice->card->driver, 0,
|
|
|
|
midi_out_ports, midi_in_ports,
|
|
|
|
&rmidi);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
snprintf(rmidi->name, sizeof(rmidi->name),
|
|
|
|
"%s MIDI", dice->card->shortname);
|
|
|
|
rmidi->private_data = dice;
|
|
|
|
|
|
|
|
if (midi_in_ports > 0) {
|
|
|
|
rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
|
|
|
|
|
|
|
|
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
|
|
|
|
&capture_ops);
|
|
|
|
|
|
|
|
str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT];
|
|
|
|
|
|
|
|
set_midi_substream_names(dice, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (midi_out_ports > 0) {
|
|
|
|
rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
|
|
|
|
|
|
|
|
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
|
|
|
|
&playback_ops);
|
|
|
|
|
|
|
|
str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];
|
|
|
|
|
|
|
|
set_midi_substream_names(dice, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((midi_out_ports > 0) && (midi_in_ports > 0))
|
|
|
|
rmidi->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|