2014-11-28 23:59:15 +08:00
|
|
|
/*
|
|
|
|
* dice_pcm.c - a part of driver for DICE based devices
|
|
|
|
*
|
|
|
|
* Copyright (c) Clemens Ladisch <clemens@ladisch.de>
|
|
|
|
* Copyright (c) 2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>
|
|
|
|
*
|
|
|
|
* Licensed under the terms of the GNU General Public License, version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dice.h"
|
|
|
|
|
2016-02-08 21:54:15 +08:00
|
|
|
static int limit_channels_and_rates(struct snd_dice *dice,
|
|
|
|
struct snd_pcm_runtime *runtime,
|
2016-03-07 21:35:44 +08:00
|
|
|
enum amdtp_stream_direction dir,
|
|
|
|
unsigned int index, unsigned int size)
|
2014-11-28 23:59:15 +08:00
|
|
|
{
|
2014-11-28 23:59:18 +08:00
|
|
|
struct snd_pcm_hardware *hw = &runtime->hw;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream;
|
2016-02-08 21:54:15 +08:00
|
|
|
unsigned int rate;
|
2016-03-07 21:35:44 +08:00
|
|
|
__be32 reg;
|
2016-02-08 21:54:15 +08:00
|
|
|
int err;
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2016-02-08 21:54:15 +08:00
|
|
|
/*
|
|
|
|
* Retrieve current Multi Bit Linear Audio data channel and limit to
|
|
|
|
* it.
|
|
|
|
*/
|
2016-03-07 21:35:44 +08:00
|
|
|
if (dir == AMDTP_IN_STREAM) {
|
|
|
|
stream = &dice->tx_stream[index];
|
|
|
|
err = snd_dice_transaction_read_tx(dice,
|
|
|
|
size * index + TX_NUMBER_AUDIO,
|
|
|
|
®, sizeof(reg));
|
2016-02-08 21:54:15 +08:00
|
|
|
} else {
|
2016-03-07 21:35:44 +08:00
|
|
|
stream = &dice->rx_stream[index];
|
|
|
|
err = snd_dice_transaction_read_rx(dice,
|
|
|
|
size * index + RX_NUMBER_AUDIO,
|
|
|
|
®, sizeof(reg));
|
2016-02-08 21:54:15 +08:00
|
|
|
}
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2016-03-07 21:35:44 +08:00
|
|
|
hw->channels_min = hw->channels_max = be32_to_cpu(reg);
|
2014-11-28 23:59:18 +08:00
|
|
|
|
2016-02-08 21:54:15 +08:00
|
|
|
/* Retrieve current sampling transfer frequency and limit to it. */
|
|
|
|
err = snd_dice_transaction_get_rate(dice, &rate);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2014-11-28 23:59:18 +08:00
|
|
|
|
2016-02-08 21:54:15 +08:00
|
|
|
hw->rates = snd_pcm_rate_to_rate_bit(rate);
|
2014-11-28 23:59:15 +08:00
|
|
|
snd_pcm_limit_hw_rates(runtime);
|
2016-02-08 21:54:15 +08:00
|
|
|
|
|
|
|
return 0;
|
2014-11-28 23:59:18 +08:00
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2014-11-28 23:59:18 +08:00
|
|
|
static void limit_period_and_buffer(struct snd_pcm_hardware *hw)
|
|
|
|
{
|
|
|
|
hw->periods_min = 2; /* SNDRV_PCM_INFO_BATCH */
|
|
|
|
hw->periods_max = UINT_MAX;
|
|
|
|
|
|
|
|
hw->period_bytes_min = 4 * hw->channels_max; /* byte for a frame */
|
|
|
|
|
|
|
|
/* Just to prevent from allocating much pages. */
|
|
|
|
hw->period_bytes_max = hw->period_bytes_min * 2048;
|
|
|
|
hw->buffer_bytes_max = hw->period_bytes_max * hw->periods_min;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int init_hw_info(struct snd_dice *dice,
|
|
|
|
struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
struct snd_pcm_hardware *hw = &runtime->hw;
|
2016-03-07 21:35:44 +08:00
|
|
|
enum amdtp_stream_direction dir;
|
2014-12-08 23:10:38 +08:00
|
|
|
struct amdtp_stream *stream;
|
2016-03-07 21:35:44 +08:00
|
|
|
__be32 reg[2];
|
|
|
|
unsigned int count, size;
|
2014-11-28 23:59:18 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
hw->info = SNDRV_PCM_INFO_MMAP |
|
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
|
|
|
SNDRV_PCM_INFO_BATCH |
|
|
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
2014-12-08 23:10:38 +08:00
|
|
|
SNDRV_PCM_INFO_JOINT_DUPLEX |
|
2014-11-28 23:59:18 +08:00
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER;
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
2015-09-19 10:22:01 +08:00
|
|
|
hw->formats = AM824_IN_PCM_FORMAT_BITS;
|
2016-03-07 21:35:44 +08:00
|
|
|
dir = AMDTP_IN_STREAM;
|
|
|
|
stream = &dice->tx_stream[substream->pcm->device];
|
|
|
|
err = snd_dice_transaction_read_tx(dice, TX_NUMBER, reg,
|
|
|
|
sizeof(reg));
|
2014-12-08 23:10:38 +08:00
|
|
|
} else {
|
2015-09-19 10:22:01 +08:00
|
|
|
hw->formats = AM824_OUT_PCM_FORMAT_BITS;
|
2016-03-07 21:35:44 +08:00
|
|
|
dir = AMDTP_OUT_STREAM;
|
|
|
|
stream = &dice->rx_stream[substream->pcm->device];
|
|
|
|
err = snd_dice_transaction_read_rx(dice, RX_NUMBER, reg,
|
|
|
|
sizeof(reg));
|
2014-12-08 23:10:38 +08:00
|
|
|
}
|
|
|
|
|
2016-03-07 21:35:44 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
count = min_t(unsigned int, be32_to_cpu(reg[0]), MAX_STREAMS);
|
|
|
|
if (substream->pcm->device >= count)
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
size = be32_to_cpu(reg[1]) * 4;
|
|
|
|
err = limit_channels_and_rates(dice, substream->runtime, dir,
|
|
|
|
substream->pcm->device, size);
|
2014-11-28 23:59:15 +08:00
|
|
|
if (err < 0)
|
2016-02-08 21:54:15 +08:00
|
|
|
return err;
|
|
|
|
limit_period_and_buffer(hw);
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2016-02-08 21:54:15 +08:00
|
|
|
return amdtp_am824_add_pcm_hw_constraints(stream, runtime);
|
2014-11-28 23:59:18 +08:00
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2014-11-28 23:59:18 +08:00
|
|
|
static int pcm_open(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
int err;
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2014-11-28 23:59:18 +08:00
|
|
|
err = snd_dice_stream_lock_try(dice);
|
|
|
|
if (err < 0)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
err = init_hw_info(dice, substream);
|
|
|
|
if (err < 0)
|
|
|
|
goto err_locked;
|
2014-12-08 23:10:37 +08:00
|
|
|
|
|
|
|
snd_pcm_set_sync(substream);
|
2014-11-28 23:59:18 +08:00
|
|
|
end:
|
|
|
|
return err;
|
|
|
|
err_locked:
|
2014-11-28 23:59:15 +08:00
|
|
|
snd_dice_stream_lock_release(dice);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pcm_close(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
|
|
|
|
snd_dice_stream_lock_release(dice);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
static int capture_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2015-08-29 09:38:46 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
|
|
|
|
params_buffer_bytes(hw_params));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2014-12-08 23:10:38 +08:00
|
|
|
|
|
|
|
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
dice->substreams_counter++;
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
}
|
|
|
|
|
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_set_pcm_format(stream, params_format(hw_params));
|
2014-12-08 23:10:38 +08:00
|
|
|
|
2015-08-29 09:38:46 +08:00
|
|
|
return 0;
|
2014-12-08 23:10:38 +08:00
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
static int playback_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2015-08-29 09:38:46 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
|
|
|
|
params_buffer_bytes(hw_params));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2014-12-08 23:10:38 +08:00
|
|
|
|
|
|
|
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
dice->substreams_counter++;
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
}
|
|
|
|
|
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_set_pcm_format(stream, params_format(hw_params));
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2015-08-29 09:38:46 +08:00
|
|
|
return 0;
|
2014-11-28 23:59:15 +08:00
|
|
|
}
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
static int capture_hw_free(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
|
|
|
|
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
|
|
|
|
dice->substreams_counter--;
|
|
|
|
|
|
|
|
snd_dice_stream_stop_duplex(dice);
|
|
|
|
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
|
|
|
return snd_pcm_lib_free_vmalloc_buffer(substream);
|
|
|
|
}
|
|
|
|
|
2014-11-28 23:59:15 +08:00
|
|
|
static int playback_hw_free(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
2014-12-08 23:10:38 +08:00
|
|
|
|
|
|
|
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
|
|
|
|
dice->substreams_counter--;
|
|
|
|
|
2014-12-08 23:10:36 +08:00
|
|
|
snd_dice_stream_stop_duplex(dice);
|
2014-12-08 23:10:38 +08:00
|
|
|
|
2014-11-28 23:59:15 +08:00
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
|
|
|
return snd_pcm_lib_free_vmalloc_buffer(substream);
|
|
|
|
}
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
static int capture_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 23:10:38 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
err = snd_dice_stream_start_duplex(dice, substream->runtime->rate);
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
if (err >= 0)
|
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_stream_pcm_prepare(stream);
|
2014-12-08 23:10:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
static int playback_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 23:59:15 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
2014-12-08 23:10:36 +08:00
|
|
|
err = snd_dice_stream_start_duplex(dice, substream->runtime->rate);
|
2014-11-28 23:59:15 +08:00
|
|
|
mutex_unlock(&dice->mutex);
|
2014-12-08 23:10:35 +08:00
|
|
|
if (err >= 0)
|
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_stream_pcm_prepare(stream);
|
2014-11-28 23:59:15 +08:00
|
|
|
|
2014-12-08 23:10:35 +08:00
|
|
|
return err;
|
2014-11-28 23:59:15 +08:00
|
|
|
}
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
static int capture_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 23:10:38 +08:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
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_stream_pcm_trigger(stream, substream);
|
2014-12-08 23:10:38 +08:00
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
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_stream_pcm_trigger(stream, NULL);
|
2014-12-08 23:10:38 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
static int playback_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 23:59:15 +08:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
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_stream_pcm_trigger(stream, substream);
|
2014-11-28 23:59:15 +08:00
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
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_stream_pcm_trigger(stream, NULL);
|
2014-11-28 23:59:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 23:10:38 +08:00
|
|
|
static snd_pcm_uframes_t capture_pointer(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 23:10:38 +08:00
|
|
|
|
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
|
|
|
return amdtp_stream_pcm_pointer(stream);
|
2014-12-08 23:10:38 +08:00
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
static snd_pcm_uframes_t playback_pointer(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 21:35:44 +08:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 23:59:15 +08:00
|
|
|
|
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
|
|
|
return amdtp_stream_pcm_pointer(stream);
|
2014-11-28 23:59:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int snd_dice_create_pcm(struct snd_dice *dice)
|
|
|
|
{
|
2016-09-02 06:13:11 +08:00
|
|
|
static const struct snd_pcm_ops capture_ops = {
|
2014-12-08 23:10:38 +08:00
|
|
|
.open = pcm_open,
|
|
|
|
.close = pcm_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
|
|
.hw_params = capture_hw_params,
|
|
|
|
.hw_free = capture_hw_free,
|
|
|
|
.prepare = capture_prepare,
|
|
|
|
.trigger = capture_trigger,
|
|
|
|
.pointer = capture_pointer,
|
|
|
|
.page = snd_pcm_lib_get_vmalloc_page,
|
|
|
|
.mmap = snd_pcm_lib_mmap_vmalloc,
|
|
|
|
};
|
2016-09-02 06:13:11 +08:00
|
|
|
static const struct snd_pcm_ops playback_ops = {
|
2014-11-28 23:59:15 +08:00
|
|
|
.open = pcm_open,
|
|
|
|
.close = pcm_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
|
|
.hw_params = playback_hw_params,
|
|
|
|
.hw_free = playback_hw_free,
|
|
|
|
.prepare = playback_prepare,
|
|
|
|
.trigger = playback_trigger,
|
|
|
|
.pointer = playback_pointer,
|
|
|
|
.page = snd_pcm_lib_get_vmalloc_page,
|
|
|
|
.mmap = snd_pcm_lib_mmap_vmalloc,
|
|
|
|
};
|
2016-02-08 21:54:18 +08:00
|
|
|
__be32 reg;
|
2014-11-28 23:59:15 +08:00
|
|
|
struct snd_pcm *pcm;
|
2016-03-07 21:35:44 +08:00
|
|
|
unsigned int i, max_capture, max_playback, capture, playback;
|
2014-11-28 23:59:15 +08:00
|
|
|
int err;
|
|
|
|
|
2016-03-07 21:35:44 +08:00
|
|
|
/* Check whether PCM substreams are required. */
|
2016-03-07 21:35:45 +08:00
|
|
|
if (dice->force_two_pcms) {
|
|
|
|
max_capture = max_playback = 2;
|
|
|
|
} else {
|
|
|
|
max_capture = max_playback = 0;
|
|
|
|
err = snd_dice_transaction_read_tx(dice, TX_NUMBER, ®,
|
|
|
|
sizeof(reg));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
max_capture = min_t(unsigned int, be32_to_cpu(reg), MAX_STREAMS);
|
2014-12-08 23:10:38 +08:00
|
|
|
|
2016-03-07 21:35:45 +08:00
|
|
|
err = snd_dice_transaction_read_rx(dice, RX_NUMBER, ®,
|
|
|
|
sizeof(reg));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
max_playback = min_t(unsigned int, be32_to_cpu(reg), MAX_STREAMS);
|
|
|
|
}
|
2016-03-07 21:35:44 +08:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_STREAMS; i++) {
|
|
|
|
capture = playback = 0;
|
|
|
|
if (i < max_capture)
|
|
|
|
capture = 1;
|
|
|
|
if (i < max_playback)
|
|
|
|
playback = 1;
|
|
|
|
if (capture == 0 && playback == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
err = snd_pcm_new(dice->card, "DICE", i, playback, capture,
|
|
|
|
&pcm);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
pcm->private_data = dice;
|
|
|
|
strcpy(pcm->name, dice->card->shortname);
|
|
|
|
|
|
|
|
if (capture > 0)
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
|
|
|
|
&capture_ops);
|
|
|
|
|
|
|
|
if (playback > 0)
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
|
|
|
&playback_ops);
|
|
|
|
}
|
2014-11-28 23:59:15 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|