Commit 5f9625a5 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-tascam: code refactoring for initialization/destruction of AMDTP stream

This commit is a preparation to support AMDTP domain.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d79360eb
...@@ -287,38 +287,60 @@ static int keep_resources(struct snd_tscm *tscm, unsigned int rate, ...@@ -287,38 +287,60 @@ static int keep_resources(struct snd_tscm *tscm, unsigned int rate,
fw_parent_device(tscm->unit)->max_speed); fw_parent_device(tscm->unit)->max_speed);
} }
int snd_tscm_stream_init_duplex(struct snd_tscm *tscm) static int init_stream(struct snd_tscm *tscm, struct amdtp_stream *s)
{ {
struct fw_iso_resources *resources;
enum amdtp_stream_direction dir;
unsigned int pcm_channels; unsigned int pcm_channels;
int err; int err;
/* For out-stream. */ if (s == &tscm->tx_stream) {
err = fw_iso_resources_init(&tscm->rx_resources, tscm->unit); resources = &tscm->tx_resources;
if (err < 0) dir = AMDTP_IN_STREAM;
return err; pcm_channels = tscm->spec->pcm_capture_analog_channels;
} else {
resources = &tscm->rx_resources;
dir = AMDTP_OUT_STREAM;
pcm_channels = tscm->spec->pcm_playback_analog_channels; pcm_channels = tscm->spec->pcm_playback_analog_channels;
}
if (tscm->spec->has_adat) if (tscm->spec->has_adat)
pcm_channels += 8; pcm_channels += 8;
if (tscm->spec->has_spdif) if (tscm->spec->has_spdif)
pcm_channels += 2; pcm_channels += 2;
err = amdtp_tscm_init(&tscm->rx_stream, tscm->unit, AMDTP_OUT_STREAM,
pcm_channels); err = fw_iso_resources_init(resources, tscm->unit);
if (err < 0) if (err < 0)
return err; return err;
/* For in-stream. */ err = amdtp_tscm_init(s, tscm->unit, dir, pcm_channels);
err = fw_iso_resources_init(&tscm->tx_resources, tscm->unit);
if (err < 0) if (err < 0)
fw_iso_resources_free(resources);
return err; return err;
pcm_channels = tscm->spec->pcm_capture_analog_channels; }
if (tscm->spec->has_adat)
pcm_channels += 8; static void destroy_stream(struct snd_tscm *tscm, struct amdtp_stream *s)
if (tscm->spec->has_spdif) {
pcm_channels += 2; amdtp_stream_destroy(s);
err = amdtp_tscm_init(&tscm->tx_stream, tscm->unit, AMDTP_IN_STREAM,
pcm_channels); if (s == &tscm->tx_stream)
fw_iso_resources_destroy(&tscm->tx_resources);
else
fw_iso_resources_destroy(&tscm->rx_resources);
}
int snd_tscm_stream_init_duplex(struct snd_tscm *tscm)
{
int err;
err = init_stream(tscm, &tscm->tx_stream);
if (err < 0) if (err < 0)
amdtp_stream_destroy(&tscm->rx_stream); return err;
err = init_stream(tscm, &tscm->rx_stream);
if (err < 0)
destroy_stream(tscm, &tscm->tx_stream);
return err; return err;
} }
...@@ -333,17 +355,12 @@ void snd_tscm_stream_update_duplex(struct snd_tscm *tscm) ...@@ -333,17 +355,12 @@ void snd_tscm_stream_update_duplex(struct snd_tscm *tscm)
amdtp_stream_stop(&tscm->rx_stream); amdtp_stream_stop(&tscm->rx_stream);
} }
/* // This function should be called before starting streams or after stopping
* This function should be called before starting streams or after stopping // streams.
* streams.
*/
void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm) void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm)
{ {
amdtp_stream_destroy(&tscm->rx_stream); destroy_stream(tscm, &tscm->rx_stream);
amdtp_stream_destroy(&tscm->tx_stream); destroy_stream(tscm, &tscm->tx_stream);
fw_iso_resources_destroy(&tscm->rx_resources);
fw_iso_resources_destroy(&tscm->tx_resources);
} }
int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate) int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment