ALSA: firewire-tascam: code refactoring for reservation of isochronous resources
This commit is a part of preparation to perform allocation/release of isochronous channels in pcm.hw_params/hw_free callbacks. This commit applies minor code refactoring for a helper function to allocate isochronous resources. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2ef0b7cf16
commit
810b37ff29
|
@ -276,34 +276,24 @@ static void release_resources(struct snd_tscm *tscm)
|
||||||
fw_iso_resources_free(&tscm->rx_resources);
|
fw_iso_resources_free(&tscm->rx_resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int keep_resources(struct snd_tscm *tscm, unsigned int rate)
|
static int keep_resources(struct snd_tscm *tscm, unsigned int rate,
|
||||||
|
struct amdtp_stream *stream)
|
||||||
{
|
{
|
||||||
|
struct fw_iso_resources *resources;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* Keep resources for in-stream. */
|
if (stream == &tscm->tx_stream)
|
||||||
err = amdtp_tscm_set_parameters(&tscm->tx_stream, rate);
|
resources = &tscm->tx_resources;
|
||||||
if (err < 0)
|
else
|
||||||
return err;
|
resources = &tscm->rx_resources;
|
||||||
err = fw_iso_resources_allocate(&tscm->tx_resources,
|
|
||||||
amdtp_stream_get_max_payload(&tscm->tx_stream),
|
|
||||||
fw_parent_device(tscm->unit)->max_speed);
|
|
||||||
if (err < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* Keep resources for out-stream. */
|
err = amdtp_tscm_set_parameters(stream, rate);
|
||||||
err = amdtp_tscm_set_parameters(&tscm->rx_stream, rate);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
err = fw_iso_resources_allocate(&tscm->rx_resources,
|
|
||||||
amdtp_stream_get_max_payload(&tscm->rx_stream),
|
|
||||||
fw_parent_device(tscm->unit)->max_speed);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
return 0;
|
return fw_iso_resources_allocate(resources,
|
||||||
error:
|
amdtp_stream_get_max_payload(stream),
|
||||||
release_resources(tscm);
|
fw_parent_device(tscm->unit)->max_speed);
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_tscm_stream_init_duplex(struct snd_tscm *tscm)
|
int snd_tscm_stream_init_duplex(struct snd_tscm *tscm)
|
||||||
|
@ -388,7 +378,11 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!amdtp_stream_running(&tscm->rx_stream)) {
|
if (!amdtp_stream_running(&tscm->rx_stream)) {
|
||||||
err = keep_resources(tscm, rate);
|
err = keep_resources(tscm, rate, &tscm->tx_stream);
|
||||||
|
if (err < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
err = keep_resources(tscm, rate, &tscm->rx_stream);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue