ALSA: bebob: support AMDTP domain

This commit adds AMDTP domain support for ALSA bebob driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Sakamoto 2019-08-04 15:21:30 +09:00 committed by Takashi Iwai
parent 42355abb9c
commit b0db4d5129
2 changed files with 29 additions and 35 deletions

View File

@ -115,6 +115,8 @@ struct snd_bebob {
/* For BeBoB version quirk. */ /* For BeBoB version quirk. */
unsigned int version; unsigned int version;
struct amdtp_domain domain;
}; };
static inline int static inline int

View File

@ -445,10 +445,9 @@ start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream)
goto end; goto end;
} }
/* start amdtp stream */ // start amdtp stream.
err = amdtp_stream_start(stream, err = amdtp_domain_add_stream(&bebob->domain, stream,
conn->resources.channel, conn->resources.channel, conn->speed);
conn->speed);
end: end:
return err; return err;
} }
@ -523,7 +522,13 @@ int snd_bebob_stream_init_duplex(struct snd_bebob *bebob)
return err; 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, static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream,
@ -566,9 +571,7 @@ int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate)
if (rate == 0) if (rate == 0)
rate = curr_rate; rate = curr_rate;
if (curr_rate != rate) { if (curr_rate != rate) {
amdtp_stream_stop(&bebob->tx_stream); amdtp_domain_stop(&bebob->domain);
amdtp_stream_stop(&bebob->rx_stream);
break_both_connections(bebob); break_both_connections(bebob);
cmp_connection_release(&bebob->out_conn); cmp_connection_release(&bebob->out_conn);
@ -620,9 +623,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
// packet queueing error or detecting discontinuity // packet queueing error or detecting discontinuity
if (amdtp_streaming_error(&bebob->rx_stream) || if (amdtp_streaming_error(&bebob->rx_stream) ||
amdtp_streaming_error(&bebob->tx_stream)) { amdtp_streaming_error(&bebob->tx_stream)) {
amdtp_stream_stop(&bebob->rx_stream); amdtp_domain_stop(&bebob->domain);
amdtp_stream_stop(&bebob->tx_stream);
break_both_connections(bebob); break_both_connections(bebob);
} }
@ -640,11 +641,16 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
return err; return err;
err = start_stream(bebob, &bebob->rx_stream); err = start_stream(bebob, &bebob->rx_stream);
if (err < 0) { if (err < 0)
dev_err(&bebob->unit->device, goto error;
"fail to run AMDTP master stream:%d\n", err);
err = start_stream(bebob, &bebob->tx_stream);
if (err < 0)
goto error;
err = amdtp_domain_start(&bebob->domain);
if (err < 0)
goto error; goto error;
}
// NOTE: // NOTE:
// The firmware customized by M-Audio uses these commands to // The firmware customized by M-Audio uses these commands to
@ -660,21 +666,8 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
} }
if (!amdtp_stream_wait_callback(&bebob->rx_stream, if (!amdtp_stream_wait_callback(&bebob->rx_stream,
CALLBACK_TIMEOUT)) { CALLBACK_TIMEOUT) ||
err = -ETIMEDOUT; !amdtp_stream_wait_callback(&bebob->tx_stream,
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)) { CALLBACK_TIMEOUT)) {
err = -ETIMEDOUT; err = -ETIMEDOUT;
goto error; goto error;
@ -683,8 +676,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
return 0; return 0;
error: error:
amdtp_stream_stop(&bebob->tx_stream); amdtp_domain_stop(&bebob->domain);
amdtp_stream_stop(&bebob->rx_stream);
break_both_connections(bebob); break_both_connections(bebob);
return err; return err;
} }
@ -692,9 +684,7 @@ error:
void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob) void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
{ {
if (bebob->substreams_counter == 0) { if (bebob->substreams_counter == 0) {
amdtp_stream_stop(&bebob->rx_stream); amdtp_domain_stop(&bebob->domain);
amdtp_stream_stop(&bebob->tx_stream);
break_both_connections(bebob); break_both_connections(bebob);
cmp_connection_release(&bebob->out_conn); cmp_connection_release(&bebob->out_conn);
@ -708,6 +698,8 @@ void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
*/ */
void snd_bebob_stream_destroy_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->tx_stream);
destroy_stream(bebob, &bebob->rx_stream); destroy_stream(bebob, &bebob->rx_stream);
} }