aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire/dice/dice.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-12-09 00:10:36 +0900
committerTakashi Iwai <tiwai@suse.de>2014-12-10 10:44:54 +0100
commit9a02843caefbc370ef6d5895881101f9436f98da (patch)
tree7dd629455220cf9e20f79bd8be51805b905058f4 /sound/firewire/dice/dice.c
parentALSA: dice: Change the way to start stream (diff)
downloadlinux-dev-9a02843caefbc370ef6d5895881101f9436f98da.tar.xz
linux-dev-9a02843caefbc370ef6d5895881101f9436f98da.zip
ALSA: dice: Add support for duplex streams with synchronization
This commit adds support for AMDTP in-stream. As a result, Dice driver supports full duplex streams with synchronization. AMDTP can transfer timestamps in its packets. By handling the timestamp, devices can synchronize to the other devices or drivers on the same bus. When Dice chipset is 'enabled', it starts streams with correct settings. This 'enable' register is global, thus, when a stream is started to run, an opposite stream can't start unless turning off 'enable'. Therefore a pair of streams must be running. This causes a loss of CPU usage when single stream is needed for neither playbacking or capturing. This commit assumes that playback-only models also have a functionality to transmit stream for delivering timestamps. Currently, sampling clock source is restricted to SYT-Match mode. This is improved in followed commit. I note that at SYT-Match mode, Dice can select from 4 streams for synchronization but this driver uses the 1st stream only for simplicity. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/dice/dice.c')
-rw-r--r--sound/firewire/dice/dice.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
index 03a7988871b6..85bcfaf3ea8a 100644
--- a/sound/firewire/dice/dice.c
+++ b/sound/firewire/dice/dice.c
@@ -30,7 +30,6 @@ static int dice_interface_check(struct fw_unit *unit)
int key, val, vendor = -1, model = -1, err;
unsigned int category, i;
__be32 *pointers, value;
- __be32 tx_data[4];
__be32 version;
pointers = kmalloc_array(ARRAY_SIZE(min_values), sizeof(__be32),
@@ -85,16 +84,6 @@ static int dice_interface_check(struct fw_unit *unit)
}
}
- /* We support playback only. Let capture devices be handled by FFADO. */
- err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST,
- DICE_PRIVATE_SPACE +
- be32_to_cpu(pointers[2]) * 4,
- tx_data, sizeof(tx_data), 0);
- if (err < 0 || (tx_data[0] && tx_data[3])) {
- err = -ENODEV;
- goto end;
- }
-
/*
* Check that the implemented DICE driver specification major version
* number matches.
@@ -142,6 +131,8 @@ static int dice_read_mode_params(struct snd_dice *dice, unsigned int mode)
int err;
if (highest_supported_mode_rate(dice, mode, &rate) < 0) {
+ dice->tx_channels[mode] = 0;
+ dice->tx_midi_ports[mode] = 0;
dice->rx_channels[mode] = 0;
dice->rx_midi_ports[mode] = 0;
return 0;
@@ -151,6 +142,14 @@ static int dice_read_mode_params(struct snd_dice *dice, unsigned int mode)
if (err < 0)
return err;
+ err = snd_dice_transaction_read_tx(dice, TX_NUMBER_AUDIO,
+ values, sizeof(values));
+ if (err < 0)
+ return err;
+
+ dice->tx_channels[mode] = be32_to_cpu(values[0]);
+ dice->tx_midi_ports[mode] = be32_to_cpu(values[1]);
+
err = snd_dice_transaction_read_rx(dice, RX_NUMBER_AUDIO,
values, sizeof(values));
if (err < 0)
@@ -280,13 +279,13 @@ static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
snd_dice_create_proc(dice);
- err = snd_dice_stream_init(dice);
+ err = snd_dice_stream_init_duplex(dice);
if (err < 0)
goto error;
err = snd_card_register(card);
if (err < 0) {
- snd_dice_stream_destroy(dice);
+ snd_dice_stream_destroy_duplex(dice);
goto error;
}
@@ -304,7 +303,7 @@ static void dice_remove(struct fw_unit *unit)
snd_card_disconnect(dice->card);
- snd_dice_stream_destroy(dice);
+ snd_dice_stream_destroy_duplex(dice);
snd_card_free_when_closed(dice->card);
}
@@ -317,7 +316,7 @@ static void dice_bus_reset(struct fw_unit *unit)
snd_dice_transaction_reinit(dice);
mutex_lock(&dice->mutex);
- snd_dice_stream_update(dice);
+ snd_dice_stream_update_duplex(dice);
mutex_unlock(&dice->mutex);
}