summaryrefslogtreecommitdiffstats
path: root/sound/firewire/dice.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/firewire/dice.c')
-rw-r--r--sound/firewire/dice.c88
1 files changed, 47 insertions, 41 deletions
diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c
index 0c3948630cf7..a9a30c0161f1 100644
--- a/sound/firewire/dice.c
+++ b/sound/firewire/dice.c
@@ -51,7 +51,7 @@ struct dice {
wait_queue_head_t hwdep_wait;
u32 notification_bits;
struct fw_iso_resources resources;
- struct amdtp_out_stream stream;
+ struct amdtp_stream stream;
};
MODULE_DESCRIPTION("DICE driver");
@@ -420,22 +420,7 @@ static int dice_open(struct snd_pcm_substream *substream)
if (err < 0)
goto err_lock;
- err = snd_pcm_hw_constraint_step(runtime, 0,
- SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32);
- if (err < 0)
- goto err_lock;
- err = snd_pcm_hw_constraint_step(runtime, 0,
- SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32);
- if (err < 0)
- goto err_lock;
-
- err = snd_pcm_hw_constraint_minmax(runtime,
- SNDRV_PCM_HW_PARAM_PERIOD_TIME,
- 5000, UINT_MAX);
- if (err < 0)
- goto err_lock;
-
- err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
+ err = amdtp_stream_add_pcm_hw_constraints(&dice->stream, runtime);
if (err < 0)
goto err_lock;
@@ -460,17 +445,17 @@ static int dice_stream_start_packets(struct dice *dice)
{
int err;
- if (amdtp_out_stream_running(&dice->stream))
+ if (amdtp_stream_running(&dice->stream))
return 0;
- err = amdtp_out_stream_start(&dice->stream, dice->resources.channel,
- fw_parent_device(dice->unit)->max_speed);
+ err = amdtp_stream_start(&dice->stream, dice->resources.channel,
+ fw_parent_device(dice->unit)->max_speed);
if (err < 0)
return err;
err = dice_enable_set(dice);
if (err < 0) {
- amdtp_out_stream_stop(&dice->stream);
+ amdtp_stream_stop(&dice->stream);
return err;
}
@@ -484,7 +469,7 @@ static int dice_stream_start(struct dice *dice)
if (!dice->resources.allocated) {
err = fw_iso_resources_allocate(&dice->resources,
- amdtp_out_stream_get_max_payload(&dice->stream),
+ amdtp_stream_get_max_payload(&dice->stream),
fw_parent_device(dice->unit)->max_speed);
if (err < 0)
goto error;
@@ -516,9 +501,9 @@ error:
static void dice_stream_stop_packets(struct dice *dice)
{
- if (amdtp_out_stream_running(&dice->stream)) {
+ if (amdtp_stream_running(&dice->stream)) {
dice_enable_clear(dice);
- amdtp_out_stream_stop(&dice->stream);
+ amdtp_stream_stop(&dice->stream);
}
}
@@ -563,7 +548,7 @@ static int dice_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
struct dice *dice = substream->private_data;
- unsigned int rate_index, mode;
+ unsigned int rate_index, mode, rate, channels, i;
int err;
mutex_lock(&dice->mutex);
@@ -575,18 +560,39 @@ static int dice_hw_params(struct snd_pcm_substream *substream,
if (err < 0)
return err;
- rate_index = rate_to_index(params_rate(hw_params));
+ rate = params_rate(hw_params);
+ rate_index = rate_to_index(rate);
err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT);
if (err < 0)
return err;
+ /*
+ * At rates above 96 kHz, pretend that the stream runs at half the
+ * actual sample rate with twice the number of channels; two samples
+ * of a channel are stored consecutively in the packet. Requires
+ * blocking mode and PCM buffer size should be aligned to SYT_INTERVAL.
+ */
+ channels = params_channels(hw_params);
+ if (rate_index > 4) {
+ if (channels > AMDTP_MAX_CHANNELS_FOR_PCM / 2) {
+ err = -ENOSYS;
+ return err;
+ }
+
+ for (i = 0; i < channels; i++) {
+ dice->stream.pcm_positions[i * 2] = i;
+ dice->stream.pcm_positions[i * 2 + 1] = i + channels;
+ }
+
+ rate /= 2;
+ channels *= 2;
+ }
+
mode = rate_index_to_mode(rate_index);
- amdtp_out_stream_set_parameters(&dice->stream,
- params_rate(hw_params),
- params_channels(hw_params),
- dice->rx_midi_ports[mode]);
- amdtp_out_stream_set_pcm_format(&dice->stream,
- params_format(hw_params));
+ amdtp_stream_set_parameters(&dice->stream, rate, channels,
+ dice->rx_midi_ports[mode]);
+ amdtp_stream_set_pcm_format(&dice->stream,
+ params_format(hw_params));
return 0;
}
@@ -609,7 +615,7 @@ static int dice_prepare(struct snd_pcm_substream *substream)
mutex_lock(&dice->mutex);
- if (amdtp_out_streaming_error(&dice->stream))
+ if (amdtp_streaming_error(&dice->stream))
dice_stream_stop_packets(dice);
err = dice_stream_start(dice);
@@ -620,7 +626,7 @@ static int dice_prepare(struct snd_pcm_substream *substream)
mutex_unlock(&dice->mutex);
- amdtp_out_stream_pcm_prepare(&dice->stream);
+ amdtp_stream_pcm_prepare(&dice->stream);
return 0;
}
@@ -640,7 +646,7 @@ static int dice_trigger(struct snd_pcm_substream *substream, int cmd)
default:
return -EINVAL;
}
- amdtp_out_stream_pcm_trigger(&dice->stream, pcm);
+ amdtp_stream_pcm_trigger(&dice->stream, pcm);
return 0;
}
@@ -649,7 +655,7 @@ static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream)
{
struct dice *dice = substream->private_data;
- return amdtp_out_stream_pcm_pointer(&dice->stream);
+ return amdtp_stream_pcm_pointer(&dice->stream);
}
static int dice_create_pcm(struct dice *dice)
@@ -1104,7 +1110,7 @@ static void dice_card_free(struct snd_card *card)
{
struct dice *dice = card->private_data;
- amdtp_out_stream_destroy(&dice->stream);
+ amdtp_stream_destroy(&dice->stream);
fw_core_remove_address_handler(&dice->notification_handler);
mutex_destroy(&dice->mutex);
}
@@ -1360,8 +1366,8 @@ static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
goto err_owner;
dice->resources.channels_mask = 0x00000000ffffffffuLL;
- err = amdtp_out_stream_init(&dice->stream, unit,
- CIP_BLOCKING | CIP_HI_DUALWIRE);
+ err = amdtp_stream_init(&dice->stream, unit, AMDTP_OUT_STREAM,
+ CIP_BLOCKING);
if (err < 0)
goto err_resources;
@@ -1417,7 +1423,7 @@ static void dice_remove(struct fw_unit *unit)
{
struct dice *dice = dev_get_drvdata(&unit->device);
- amdtp_out_stream_pcm_abort(&dice->stream);
+ amdtp_stream_pcm_abort(&dice->stream);
snd_card_disconnect(dice->card);
@@ -1443,7 +1449,7 @@ static void dice_bus_reset(struct fw_unit *unit)
* to stop so that the application can restart them in an orderly
* manner.
*/
- amdtp_out_stream_pcm_abort(&dice->stream);
+ amdtp_stream_pcm_abort(&dice->stream);
mutex_lock(&dice->mutex);