2019-05-30 02:57:59 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-11-28 18:59:15 +03: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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dice.h"
|
|
|
|
|
2018-05-02 13:16:50 +03:00
|
|
|
static int dice_rate_constraint(struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_pcm_hw_rule *rule)
|
|
|
|
{
|
|
|
|
struct snd_pcm_substream *substream = rule->private;
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
unsigned int index = substream->pcm->device;
|
|
|
|
|
|
|
|
const struct snd_interval *c =
|
|
|
|
hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
|
|
|
struct snd_interval *r =
|
|
|
|
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
|
|
|
|
struct snd_interval rates = {
|
|
|
|
.min = UINT_MAX, .max = 0, .integer = 1
|
|
|
|
};
|
|
|
|
unsigned int *pcm_channels;
|
|
|
|
enum snd_dice_rate_mode mode;
|
|
|
|
unsigned int i, rate;
|
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
|
|
|
|
pcm_channels = dice->tx_pcm_chs[index];
|
|
|
|
else
|
|
|
|
pcm_channels = dice->rx_pcm_chs[index];
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(snd_dice_rates); ++i) {
|
|
|
|
rate = snd_dice_rates[i];
|
|
|
|
if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!snd_interval_test(c, pcm_channels[mode]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rates.min = min(rates.min, rate);
|
|
|
|
rates.max = max(rates.max, rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return snd_interval_refine(r, &rates);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dice_channels_constraint(struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_pcm_hw_rule *rule)
|
|
|
|
{
|
|
|
|
struct snd_pcm_substream *substream = rule->private;
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
unsigned int index = substream->pcm->device;
|
|
|
|
|
|
|
|
const struct snd_interval *r =
|
|
|
|
hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE);
|
|
|
|
struct snd_interval *c =
|
|
|
|
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
|
|
|
struct snd_interval channels = {
|
|
|
|
.min = UINT_MAX, .max = 0, .integer = 1
|
|
|
|
};
|
|
|
|
unsigned int *pcm_channels;
|
|
|
|
enum snd_dice_rate_mode mode;
|
|
|
|
unsigned int i, rate;
|
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
|
|
|
|
pcm_channels = dice->tx_pcm_chs[index];
|
|
|
|
else
|
|
|
|
pcm_channels = dice->rx_pcm_chs[index];
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(snd_dice_rates); ++i) {
|
|
|
|
rate = snd_dice_rates[i];
|
|
|
|
if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!snd_interval_test(r, rate))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
channels.min = min(channels.min, pcm_channels[mode]);
|
|
|
|
channels.max = max(channels.max, pcm_channels[mode]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return snd_interval_refine(c, &channels);
|
|
|
|
}
|
|
|
|
|
2016-02-08 16:54:15 +03:00
|
|
|
static int limit_channels_and_rates(struct snd_dice *dice,
|
|
|
|
struct snd_pcm_runtime *runtime,
|
2016-03-07 16:35:44 +03:00
|
|
|
enum amdtp_stream_direction dir,
|
2018-05-02 13:16:50 +03:00
|
|
|
unsigned int index)
|
2014-11-28 18:59:15 +03:00
|
|
|
{
|
2014-11-28 18:59:18 +03:00
|
|
|
struct snd_pcm_hardware *hw = &runtime->hw;
|
2018-05-02 13:16:50 +03:00
|
|
|
unsigned int *pcm_channels;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (dir == AMDTP_IN_STREAM)
|
|
|
|
pcm_channels = dice->tx_pcm_chs[index];
|
|
|
|
else
|
|
|
|
pcm_channels = dice->rx_pcm_chs[index];
|
|
|
|
|
|
|
|
hw->channels_min = UINT_MAX;
|
|
|
|
hw->channels_max = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(snd_dice_rates); ++i) {
|
|
|
|
enum snd_dice_rate_mode mode;
|
|
|
|
unsigned int rate, channels;
|
|
|
|
|
|
|
|
rate = snd_dice_rates[i];
|
|
|
|
if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0)
|
|
|
|
continue;
|
|
|
|
hw->rates |= snd_pcm_rate_to_rate_bit(rate);
|
|
|
|
|
|
|
|
channels = pcm_channels[mode];
|
|
|
|
if (channels == 0)
|
|
|
|
continue;
|
|
|
|
hw->channels_min = min(hw->channels_min, channels);
|
|
|
|
hw->channels_max = max(hw->channels_max, channels);
|
2016-02-08 16:54:15 +03:00
|
|
|
}
|
2014-11-28 18:59:18 +03:00
|
|
|
|
2014-11-28 18:59:15 +03:00
|
|
|
snd_pcm_limit_hw_rates(runtime);
|
2016-02-08 16:54:15 +03:00
|
|
|
|
|
|
|
return 0;
|
2014-11-28 18:59:18 +03:00
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2014-11-28 18:59:18 +03:00
|
|
|
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;
|
2018-05-02 13:16:50 +03:00
|
|
|
unsigned int index = substream->pcm->device;
|
2016-03-07 16:35:44 +03:00
|
|
|
enum amdtp_stream_direction dir;
|
2014-12-08 18:10:38 +03:00
|
|
|
struct amdtp_stream *stream;
|
2014-11-28 18:59:18 +03:00
|
|
|
int err;
|
|
|
|
|
2014-12-08 18:10:38 +03:00
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
2015-09-19 05:22:01 +03:00
|
|
|
hw->formats = AM824_IN_PCM_FORMAT_BITS;
|
2016-03-07 16:35:44 +03:00
|
|
|
dir = AMDTP_IN_STREAM;
|
2018-05-02 13:16:50 +03:00
|
|
|
stream = &dice->tx_stream[index];
|
2014-12-08 18:10:38 +03:00
|
|
|
} else {
|
2015-09-19 05:22:01 +03:00
|
|
|
hw->formats = AM824_OUT_PCM_FORMAT_BITS;
|
2016-03-07 16:35:44 +03:00
|
|
|
dir = AMDTP_OUT_STREAM;
|
2018-05-02 13:16:50 +03:00
|
|
|
stream = &dice->rx_stream[index];
|
2014-12-08 18:10:38 +03:00
|
|
|
}
|
|
|
|
|
2018-05-02 13:16:50 +03:00
|
|
|
err = limit_channels_and_rates(dice, substream->runtime, dir,
|
|
|
|
index);
|
2016-03-07 16:35:44 +03:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2018-05-02 13:16:50 +03:00
|
|
|
err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
|
|
|
|
dice_rate_constraint, substream,
|
|
|
|
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
|
|
|
|
dice_channels_constraint, substream,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE, -1);
|
2014-11-28 18:59:15 +03:00
|
|
|
if (err < 0)
|
2016-02-08 16:54:15 +03:00
|
|
|
return err;
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2016-02-08 16:54:15 +03:00
|
|
|
return amdtp_am824_add_pcm_hw_constraints(stream, runtime);
|
2014-11-28 18:59:18 +03:00
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2014-11-28 18:59:18 +03:00
|
|
|
static int pcm_open(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2019-10-07 14:05:28 +03:00
|
|
|
struct amdtp_domain *d = &dice->domain;
|
2018-05-02 13:16:50 +03:00
|
|
|
unsigned int source;
|
|
|
|
bool internal;
|
2014-11-28 18:59:18 +03:00
|
|
|
int err;
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2014-11-28 18:59:18 +03:00
|
|
|
err = snd_dice_stream_lock_try(dice);
|
|
|
|
if (err < 0)
|
2019-10-07 14:05:28 +03:00
|
|
|
return err;
|
2014-11-28 18:59:18 +03:00
|
|
|
|
|
|
|
err = init_hw_info(dice, substream);
|
|
|
|
if (err < 0)
|
|
|
|
goto err_locked;
|
2014-12-08 18:10:37 +03:00
|
|
|
|
2018-05-02 13:16:50 +03:00
|
|
|
err = snd_dice_transaction_get_clock_source(dice, &source);
|
|
|
|
if (err < 0)
|
|
|
|
goto err_locked;
|
|
|
|
switch (source) {
|
|
|
|
case CLOCK_SOURCE_AES1:
|
|
|
|
case CLOCK_SOURCE_AES2:
|
|
|
|
case CLOCK_SOURCE_AES3:
|
|
|
|
case CLOCK_SOURCE_AES4:
|
|
|
|
case CLOCK_SOURCE_AES_ANY:
|
|
|
|
case CLOCK_SOURCE_ADAT:
|
|
|
|
case CLOCK_SOURCE_TDIF:
|
|
|
|
case CLOCK_SOURCE_WC:
|
|
|
|
internal = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
internal = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-07 14:05:28 +03:00
|
|
|
mutex_lock(&dice->mutex);
|
|
|
|
|
|
|
|
// When source of clock is not internal or any stream is reserved for
|
|
|
|
// transmission of PCM frames, the available sampling rate is limited
|
|
|
|
// at current one.
|
2018-05-02 13:16:50 +03:00
|
|
|
if (!internal ||
|
2019-10-07 14:05:28 +03:00
|
|
|
(dice->substreams_counter > 0 && d->events_per_period > 0)) {
|
|
|
|
unsigned int frames_per_period = d->events_per_period;
|
2019-10-17 18:54:17 +03:00
|
|
|
unsigned int frames_per_buffer = d->events_per_buffer;
|
2018-05-02 13:16:50 +03:00
|
|
|
unsigned int rate;
|
|
|
|
|
|
|
|
err = snd_dice_transaction_get_rate(dice, &rate);
|
2019-10-07 14:05:28 +03:00
|
|
|
if (err < 0) {
|
|
|
|
mutex_unlock(&dice->mutex);
|
2018-05-02 13:16:50 +03:00
|
|
|
goto err_locked;
|
2019-10-07 14:05:28 +03:00
|
|
|
}
|
|
|
|
|
2018-05-02 13:16:50 +03:00
|
|
|
substream->runtime->hw.rate_min = rate;
|
|
|
|
substream->runtime->hw.rate_max = rate;
|
2019-10-07 14:05:28 +03:00
|
|
|
|
|
|
|
if (frames_per_period > 0) {
|
|
|
|
// For double_pcm_frame quirk.
|
2019-10-17 18:54:17 +03:00
|
|
|
if (rate > 96000) {
|
2019-10-07 14:05:28 +03:00
|
|
|
frames_per_period *= 2;
|
2019-10-17 18:54:17 +03:00
|
|
|
frames_per_buffer *= 2;
|
|
|
|
}
|
2019-10-07 14:05:28 +03:00
|
|
|
|
|
|
|
err = snd_pcm_hw_constraint_minmax(substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
|
|
|
|
frames_per_period, frames_per_period);
|
|
|
|
if (err < 0) {
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
goto err_locked;
|
|
|
|
}
|
2019-10-17 18:54:17 +03:00
|
|
|
|
|
|
|
err = snd_pcm_hw_constraint_minmax(substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
|
|
|
|
frames_per_buffer, frames_per_buffer);
|
|
|
|
if (err < 0) {
|
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
goto err_locked;
|
|
|
|
}
|
2019-10-07 14:05:28 +03:00
|
|
|
}
|
2018-05-02 13:16:50 +03:00
|
|
|
}
|
|
|
|
|
2019-10-07 14:05:28 +03:00
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
2014-12-08 18:10:37 +03:00
|
|
|
snd_pcm_set_sync(substream);
|
2019-10-07 14:05:28 +03:00
|
|
|
|
|
|
|
return 0;
|
2014-11-28 18:59:18 +03:00
|
|
|
err_locked:
|
2014-11-28 18:59:15 +03: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;
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:21:18 +03:00
|
|
|
static int pcm_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
2014-12-08 18:10:38 +03:00
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2015-08-29 04:38:46 +03:00
|
|
|
int err;
|
|
|
|
|
2019-11-05 18:18:42 +03:00
|
|
|
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
|
2015-08-29 04:38:46 +03:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2014-12-08 18:10:38 +03:00
|
|
|
|
|
|
|
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
|
2019-06-11 16:21:16 +03:00
|
|
|
unsigned int rate = params_rate(hw_params);
|
2019-10-07 14:05:20 +03:00
|
|
|
unsigned int events_per_period = params_period_size(hw_params);
|
2019-10-17 18:54:17 +03:00
|
|
|
unsigned int events_per_buffer = params_buffer_size(hw_params);
|
2019-06-11 16:21:16 +03:00
|
|
|
|
2014-12-08 18:10:38 +03:00
|
|
|
mutex_lock(&dice->mutex);
|
2019-10-07 14:05:20 +03:00
|
|
|
// For double_pcm_frame quirk.
|
2019-10-17 18:54:17 +03:00
|
|
|
if (rate > 96000) {
|
2019-10-07 14:05:20 +03:00
|
|
|
events_per_period /= 2;
|
2019-10-17 18:54:17 +03:00
|
|
|
events_per_buffer /= 2;
|
|
|
|
}
|
2019-10-07 14:05:20 +03:00
|
|
|
err = snd_dice_stream_reserve_duplex(dice, rate,
|
2019-10-17 18:54:17 +03:00
|
|
|
events_per_period, events_per_buffer);
|
2019-06-11 16:21:16 +03:00
|
|
|
if (err >= 0)
|
|
|
|
++dice->substreams_counter;
|
2014-12-08 18:10:38 +03:00
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:21:16 +03:00
|
|
|
return err;
|
2014-12-08 18:10:38 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:21:18 +03:00
|
|
|
static int pcm_hw_free(struct snd_pcm_substream *substream)
|
2014-11-28 18:59:15 +03:00
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
2014-12-08 18:10:38 +03:00
|
|
|
|
|
|
|
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
|
2019-06-11 16:21:16 +03:00
|
|
|
--dice->substreams_counter;
|
2014-12-08 18:10:38 +03:00
|
|
|
|
2014-12-08 18:10:36 +03:00
|
|
|
snd_dice_stream_stop_duplex(dice);
|
2014-12-08 18:10:38 +03:00
|
|
|
|
2014-11-28 18:59:15 +03:00
|
|
|
mutex_unlock(&dice->mutex);
|
|
|
|
|
2019-11-05 18:18:42 +03:00
|
|
|
return snd_pcm_lib_free_pages(substream);
|
2014-11-28 18:59:15 +03:00
|
|
|
}
|
|
|
|
|
2014-12-08 18:10:38 +03:00
|
|
|
static int capture_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 18:10:38 +03:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
2019-06-11 16:21:16 +03:00
|
|
|
err = snd_dice_stream_start_duplex(dice);
|
2014-12-08 18:10:38 +03:00
|
|
|
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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_prepare(stream);
|
2014-12-08 18:10:38 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
static int playback_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 18:59:15 +03:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&dice->mutex);
|
2019-06-11 16:21:16 +03:00
|
|
|
err = snd_dice_stream_start_duplex(dice);
|
2014-11-28 18:59:15 +03:00
|
|
|
mutex_unlock(&dice->mutex);
|
2014-12-08 18:10:35 +03: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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_prepare(stream);
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2014-12-08 18:10:35 +03:00
|
|
|
return err;
|
2014-11-28 18:59:15 +03:00
|
|
|
}
|
|
|
|
|
2014-12-08 18:10:38 +03:00
|
|
|
static int capture_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 18:10:38 +03: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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_trigger(stream, substream);
|
2014-12-08 18:10:38 +03: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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_trigger(stream, NULL);
|
2014-12-08 18:10:38 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
static int playback_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 18:59:15 +03: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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_trigger(stream, substream);
|
2014-11-28 18:59:15 +03: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 16:35:42 +03:00
|
|
|
amdtp_stream_pcm_trigger(stream, NULL);
|
2014-11-28 18:59:15 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 18:10:38 +03:00
|
|
|
static snd_pcm_uframes_t capture_pointer(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
2014-12-08 18:10:38 +03:00
|
|
|
|
2019-10-18 09:19:07 +03:00
|
|
|
return amdtp_domain_stream_pcm_pointer(&dice->domain, stream);
|
2014-12-08 18:10:38 +03:00
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
static snd_pcm_uframes_t playback_pointer(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
2016-03-07 16:35:44 +03:00
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
2014-11-28 18:59:15 +03:00
|
|
|
|
2019-10-18 09:19:07 +03:00
|
|
|
return amdtp_domain_stream_pcm_pointer(&dice->domain, stream);
|
2014-11-28 18:59:15 +03:00
|
|
|
}
|
|
|
|
|
2017-06-07 03:38:05 +03:00
|
|
|
static int capture_ack(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
|
|
|
|
|
2019-10-18 09:19:08 +03:00
|
|
|
return amdtp_domain_stream_pcm_ack(&dice->domain, stream);
|
2017-06-07 03:38:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int playback_ack(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_dice *dice = substream->private_data;
|
|
|
|
struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
|
|
|
|
|
2019-10-18 09:19:08 +03:00
|
|
|
return amdtp_domain_stream_pcm_ack(&dice->domain, stream);
|
2017-06-07 03:38:05 +03:00
|
|
|
}
|
|
|
|
|
2014-11-28 18:59:15 +03:00
|
|
|
int snd_dice_create_pcm(struct snd_dice *dice)
|
|
|
|
{
|
2016-09-02 01:13:11 +03:00
|
|
|
static const struct snd_pcm_ops capture_ops = {
|
2014-12-08 18:10:38 +03:00
|
|
|
.open = pcm_open,
|
|
|
|
.close = pcm_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
2019-06-11 16:21:18 +03:00
|
|
|
.hw_params = pcm_hw_params,
|
|
|
|
.hw_free = pcm_hw_free,
|
2014-12-08 18:10:38 +03:00
|
|
|
.prepare = capture_prepare,
|
|
|
|
.trigger = capture_trigger,
|
|
|
|
.pointer = capture_pointer,
|
2017-06-07 03:38:05 +03:00
|
|
|
.ack = capture_ack,
|
2014-12-08 18:10:38 +03:00
|
|
|
};
|
2016-09-02 01:13:11 +03:00
|
|
|
static const struct snd_pcm_ops playback_ops = {
|
2014-11-28 18:59:15 +03:00
|
|
|
.open = pcm_open,
|
|
|
|
.close = pcm_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
2019-06-11 16:21:18 +03:00
|
|
|
.hw_params = pcm_hw_params,
|
|
|
|
.hw_free = pcm_hw_free,
|
2014-11-28 18:59:15 +03:00
|
|
|
.prepare = playback_prepare,
|
|
|
|
.trigger = playback_trigger,
|
|
|
|
.pointer = playback_pointer,
|
2017-06-07 03:38:05 +03:00
|
|
|
.ack = playback_ack,
|
2014-11-28 18:59:15 +03:00
|
|
|
};
|
|
|
|
struct snd_pcm *pcm;
|
ALSA: dice: remove local frag of force_two_pcms
At present, to add PCM substreams for each of available tx/rx streams,
this driver uses a condition based on model-name. This is not enough
to support unknown models.
In former commits, this driver gains cache of stream formats. For models
which support protocol extension, all of available steam formats are
cached. For known models, hard-coded stream formats are used to generate
the cache. For unknown models, stream formats at current mode of sampling
transmission frequency is cached.
Anyway, at least, the cached formats are used to expose constrains of PCM
substreams for userspace applications. Thus, The cached data can be also
used to add PCM substreams themselves, instead of the name-based
conditions.
This commit obsoletes local frag of force_two_pcms.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-05-02 13:16:51 +03:00
|
|
|
unsigned int capture, playback;
|
|
|
|
int i, j;
|
2014-11-28 18:59:15 +03:00
|
|
|
int err;
|
|
|
|
|
2016-03-07 16:35:44 +03:00
|
|
|
for (i = 0; i < MAX_STREAMS; i++) {
|
|
|
|
capture = playback = 0;
|
ALSA: dice: remove local frag of force_two_pcms
At present, to add PCM substreams for each of available tx/rx streams,
this driver uses a condition based on model-name. This is not enough
to support unknown models.
In former commits, this driver gains cache of stream formats. For models
which support protocol extension, all of available steam formats are
cached. For known models, hard-coded stream formats are used to generate
the cache. For unknown models, stream formats at current mode of sampling
transmission frequency is cached.
Anyway, at least, the cached formats are used to expose constrains of PCM
substreams for userspace applications. Thus, The cached data can be also
used to add PCM substreams themselves, instead of the name-based
conditions.
This commit obsoletes local frag of force_two_pcms.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-05-02 13:16:51 +03:00
|
|
|
for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j) {
|
|
|
|
if (dice->tx_pcm_chs[i][j] > 0)
|
|
|
|
capture = 1;
|
|
|
|
if (dice->rx_pcm_chs[i][j] > 0)
|
|
|
|
playback = 1;
|
|
|
|
}
|
2016-03-07 16:35:44 +03:00
|
|
|
|
|
|
|
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);
|
2019-11-05 18:18:42 +03:00
|
|
|
|
|
|
|
snd_pcm_lib_preallocate_pages_for_all(pcm,
|
|
|
|
SNDRV_DMA_TYPE_VMALLOC,
|
|
|
|
NULL, 0, 0);
|
2016-03-07 16:35:44 +03:00
|
|
|
}
|
2014-11-28 18:59:15 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|