Skip to content

Commit c9a9ce8

Browse files
takaswietiwai
authored andcommitted
ALSA: fireface: support AMDTP domain
This commit adds AMDTP domain support for ALSA fireface driver. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ccc6c1b commit c9a9ce8

2 files changed

Lines changed: 35 additions & 24 deletions

File tree

‎sound/firewire/fireface/ff-stream.c‎

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc,
3232

3333
static inline void finish_session(struct snd_ff *ff)
3434
{
35-
amdtp_stream_stop(&ff->tx_stream);
36-
amdtp_stream_stop(&ff->rx_stream);
37-
3835
ff->spec->protocol->finish_session(ff);
3936
ff->spec->protocol->switch_fetching_mode(ff, false);
4037
}
@@ -83,8 +80,16 @@ int snd_ff_stream_init_duplex(struct snd_ff *ff)
8380
return err;
8481

8582
err = init_stream(ff, &ff->tx_stream);
86-
if (err < 0)
83+
if (err < 0) {
8784
destroy_stream(ff, &ff->rx_stream);
85+
return err;
86+
}
87+
88+
err = amdtp_domain_init(&ff->domain);
89+
if (err < 0) {
90+
destroy_stream(ff, &ff->rx_stream);
91+
destroy_stream(ff, &ff->tx_stream);
92+
}
8893

8994
return err;
9095
}
@@ -95,6 +100,8 @@ int snd_ff_stream_init_duplex(struct snd_ff *ff)
95100
*/
96101
void snd_ff_stream_destroy_duplex(struct snd_ff *ff)
97102
{
103+
amdtp_domain_destroy(&ff->domain);
104+
98105
destroy_stream(ff, &ff->rx_stream);
99106
destroy_stream(ff, &ff->tx_stream);
100107
}
@@ -113,6 +120,7 @@ int snd_ff_stream_reserve_duplex(struct snd_ff *ff, unsigned int rate)
113120
enum snd_ff_stream_mode mode;
114121
int i;
115122

123+
amdtp_domain_stop(&ff->domain);
116124
finish_session(ff);
117125

118126
fw_iso_resources_free(&ff->tx_resources);
@@ -155,51 +163,52 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
155163
return 0;
156164

157165
if (amdtp_streaming_error(&ff->tx_stream) ||
158-
amdtp_streaming_error(&ff->rx_stream))
166+
amdtp_streaming_error(&ff->rx_stream)) {
167+
amdtp_domain_stop(&ff->domain);
159168
finish_session(ff);
169+
}
160170

161171
/*
162172
* Regardless of current source of clock signal, drivers transfer some
163173
* packets. Then, the device transfers packets.
164174
*/
165175
if (!amdtp_stream_running(&ff->rx_stream)) {
176+
int spd = fw_parent_device(ff->unit)->max_speed;
177+
166178
err = ff->spec->protocol->begin_session(ff, rate);
167179
if (err < 0)
168180
goto error;
169181

170-
err = amdtp_stream_start(&ff->rx_stream,
171-
ff->rx_resources.channel,
172-
fw_parent_device(ff->unit)->max_speed);
182+
err = amdtp_domain_add_stream(&ff->domain, &ff->rx_stream,
183+
ff->rx_resources.channel, spd);
173184
if (err < 0)
174185
goto error;
175186

176-
if (!amdtp_stream_wait_callback(&ff->rx_stream,
177-
CALLBACK_TIMEOUT_MS)) {
178-
err = -ETIMEDOUT;
179-
goto error;
180-
}
181-
182-
err = ff->spec->protocol->switch_fetching_mode(ff, true);
187+
err = amdtp_domain_add_stream(&ff->domain, &ff->tx_stream,
188+
ff->tx_resources.channel, spd);
183189
if (err < 0)
184190
goto error;
185-
}
186191

187-
if (!amdtp_stream_running(&ff->tx_stream)) {
188-
err = amdtp_stream_start(&ff->tx_stream,
189-
ff->tx_resources.channel,
190-
fw_parent_device(ff->unit)->max_speed);
192+
err = amdtp_domain_start(&ff->domain);
191193
if (err < 0)
192194
goto error;
193195

194-
if (!amdtp_stream_wait_callback(&ff->tx_stream,
196+
if (!amdtp_stream_wait_callback(&ff->rx_stream,
197+
CALLBACK_TIMEOUT_MS) ||
198+
!amdtp_stream_wait_callback(&ff->tx_stream,
195199
CALLBACK_TIMEOUT_MS)) {
196200
err = -ETIMEDOUT;
197201
goto error;
198202
}
203+
204+
err = ff->spec->protocol->switch_fetching_mode(ff, true);
205+
if (err < 0)
206+
goto error;
199207
}
200208

201209
return 0;
202210
error:
211+
amdtp_domain_stop(&ff->domain);
203212
finish_session(ff);
204213

205214
return err;
@@ -208,6 +217,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
208217
void snd_ff_stream_stop_duplex(struct snd_ff *ff)
209218
{
210219
if (ff->substreams_counter == 0) {
220+
amdtp_domain_stop(&ff->domain);
211221
finish_session(ff);
212222

213223
fw_iso_resources_free(&ff->tx_resources);
@@ -217,12 +227,11 @@ void snd_ff_stream_stop_duplex(struct snd_ff *ff)
217227

218228
void snd_ff_stream_update_duplex(struct snd_ff *ff)
219229
{
230+
amdtp_domain_stop(&ff->domain);
231+
220232
// The device discontinue to transfer packets.
221233
amdtp_stream_pcm_abort(&ff->tx_stream);
222-
amdtp_stream_stop(&ff->tx_stream);
223-
224234
amdtp_stream_pcm_abort(&ff->rx_stream);
225-
amdtp_stream_stop(&ff->rx_stream);
226235
}
227236

228237
void snd_ff_stream_lock_changed(struct snd_ff *ff)

‎sound/firewire/fireface/ff.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct snd_ff {
9191
int dev_lock_count;
9292
bool dev_lock_changed;
9393
wait_queue_head_t hwdep_wait;
94+
95+
struct amdtp_domain domain;
9496
};
9597

9698
enum snd_ff_clock_src {

0 commit comments

Comments
 (0)