ALSA: dice: support dual-wire stream format at 192 kHz
Change the AMDTP streaming code to handle the non-standard stream format
that DICE devices use at sample rates greater than 96 kHz.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c
index b4827ff..8804e42 100644
--- a/sound/firewire/dice.c
+++ b/sound/firewire/dice.c
@@ -375,7 +375,7 @@
struct dice *dice = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
__be32 clock_sel, number_audio, number_midi;
- unsigned int rate;
+ unsigned int rate_index, rate;
int err;
err = dice_try_lock(dice);
@@ -387,12 +387,13 @@
&clock_sel, 4);
if (err < 0)
goto err_lock;
- rate = (be32_to_cpu(clock_sel) & CLOCK_RATE_MASK) >> CLOCK_RATE_SHIFT;
- if (rate >= ARRAY_SIZE(dice_rates)) {
+ rate_index = (be32_to_cpu(clock_sel) & CLOCK_RATE_MASK)
+ >> CLOCK_RATE_SHIFT;
+ if (rate_index >= ARRAY_SIZE(dice_rates)) {
err = -ENXIO;
goto err_lock;
}
- rate = dice_rates[rate];
+ rate = dice_rates[rate_index];
err = snd_fw_transaction(dice->unit, TCODE_READ_QUADLET_REQUEST,
rx_address(dice, RX_NUMBER_AUDIO),
@@ -413,9 +414,20 @@
runtime->hw.channels_min = be32_to_cpu(number_audio);
runtime->hw.channels_max = be32_to_cpu(number_audio);
- amdtp_out_stream_set_rate(&dice->stream, rate);
- amdtp_out_stream_set_pcm(&dice->stream, be32_to_cpu(number_audio));
- amdtp_out_stream_set_midi(&dice->stream, be32_to_cpu(number_midi));
+ amdtp_out_stream_set_parameters(&dice->stream, rate,
+ be32_to_cpu(number_audio),
+ be32_to_cpu(number_midi));
+
+ err = snd_pcm_hw_constraint_step(runtime, 0,
+ SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ amdtp_syt_intervals[rate_index]);
+ if (err < 0)
+ goto err_lock;
+ err = snd_pcm_hw_constraint_step(runtime, 0,
+ SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+ amdtp_syt_intervals[rate_index]);
+ if (err < 0)
+ goto err_lock;
err = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
@@ -993,7 +1005,8 @@
goto err_notification_handler;
dice->resources.channels_mask = 0x00000000ffffffffuLL;
- err = amdtp_out_stream_init(&dice->stream, unit, CIP_BLOCKING);
+ err = amdtp_out_stream_init(&dice->stream, unit,
+ CIP_BLOCKING | CIP_HI_DUALWIRE);
if (err < 0)
goto err_resources;