Skip to content

Commit

Permalink
ALSA: bebob: support AMDTP domain
Browse files Browse the repository at this point in the history
This commit adds AMDTP domain support for ALSA bebob driver.

Signed-off-by: Takashi Sakamoto <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
takaswie authored and tiwai committed Aug 5, 2019
1 parent 42355ab commit b0db4d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
2 changes: 2 additions & 0 deletions sound/firewire/bebob/bebob.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ struct snd_bebob {

/* For BeBoB version quirk. */
unsigned int version;

struct amdtp_domain domain;
};

static inline int
Expand Down
62 changes: 27 additions & 35 deletions sound/firewire/bebob/bebob_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,9 @@ start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream)
goto end;
}

/* start amdtp stream */
err = amdtp_stream_start(stream,
conn->resources.channel,
conn->speed);
// start amdtp stream.
err = amdtp_domain_add_stream(&bebob->domain, stream,
conn->resources.channel, conn->speed);
end:
return err;
}
Expand Down Expand Up @@ -523,7 +522,13 @@ int snd_bebob_stream_init_duplex(struct snd_bebob *bebob)
return err;
}

return 0;
err = amdtp_domain_init(&bebob->domain);
if (err < 0) {
destroy_stream(bebob, &bebob->tx_stream);
destroy_stream(bebob, &bebob->rx_stream);
}

return err;
}

static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream,
Expand Down Expand Up @@ -566,9 +571,7 @@ int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate)
if (rate == 0)
rate = curr_rate;
if (curr_rate != rate) {
amdtp_stream_stop(&bebob->tx_stream);
amdtp_stream_stop(&bebob->rx_stream);

amdtp_domain_stop(&bebob->domain);
break_both_connections(bebob);

cmp_connection_release(&bebob->out_conn);
Expand Down Expand Up @@ -620,9 +623,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
// packet queueing error or detecting discontinuity
if (amdtp_streaming_error(&bebob->rx_stream) ||
amdtp_streaming_error(&bebob->tx_stream)) {
amdtp_stream_stop(&bebob->rx_stream);
amdtp_stream_stop(&bebob->tx_stream);

amdtp_domain_stop(&bebob->domain);
break_both_connections(bebob);
}

Expand All @@ -640,11 +641,16 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
return err;

err = start_stream(bebob, &bebob->rx_stream);
if (err < 0) {
dev_err(&bebob->unit->device,
"fail to run AMDTP master stream:%d\n", err);
if (err < 0)
goto error;

err = start_stream(bebob, &bebob->tx_stream);
if (err < 0)
goto error;

err = amdtp_domain_start(&bebob->domain);
if (err < 0)
goto error;
}

// NOTE:
// The firmware customized by M-Audio uses these commands to
Expand All @@ -660,21 +666,8 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
}

if (!amdtp_stream_wait_callback(&bebob->rx_stream,
CALLBACK_TIMEOUT)) {
err = -ETIMEDOUT;
goto error;
}
}

if (!amdtp_stream_running(&bebob->tx_stream)) {
err = start_stream(bebob, &bebob->tx_stream);
if (err < 0) {
dev_err(&bebob->unit->device,
"fail to run AMDTP slave stream:%d\n", err);
goto error;
}

if (!amdtp_stream_wait_callback(&bebob->tx_stream,
CALLBACK_TIMEOUT) ||
!amdtp_stream_wait_callback(&bebob->tx_stream,
CALLBACK_TIMEOUT)) {
err = -ETIMEDOUT;
goto error;
Expand All @@ -683,18 +676,15 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)

return 0;
error:
amdtp_stream_stop(&bebob->tx_stream);
amdtp_stream_stop(&bebob->rx_stream);
amdtp_domain_stop(&bebob->domain);
break_both_connections(bebob);
return err;
}

void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
{
if (bebob->substreams_counter == 0) {
amdtp_stream_stop(&bebob->rx_stream);
amdtp_stream_stop(&bebob->tx_stream);

amdtp_domain_stop(&bebob->domain);
break_both_connections(bebob);

cmp_connection_release(&bebob->out_conn);
Expand All @@ -708,6 +698,8 @@ void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
*/
void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob)
{
amdtp_domain_destroy(&bebob->domain);

destroy_stream(bebob, &bebob->tx_stream);
destroy_stream(bebob, &bebob->rx_stream);
}
Expand Down

0 comments on commit b0db4d5

Please sign in to comment.