.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * motu-stream.c - a part of driver for MOTU FireWire series |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp> |
---|
5 | | - * |
---|
6 | | - * Licensed under the terms of the GNU General Public License, version 2. |
---|
7 | 6 | */ |
---|
8 | 7 | |
---|
9 | 8 | #include "motu.h" |
---|
.. | .. |
---|
26 | 25 | #define RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS 0x00000040 |
---|
27 | 26 | #define TX_PACKET_TRANSMISSION_SPEED_MASK 0x0000000f |
---|
28 | 27 | |
---|
29 | | -static int start_both_streams(struct snd_motu *motu, unsigned int rate) |
---|
| 28 | +static int keep_resources(struct snd_motu *motu, unsigned int rate, |
---|
| 29 | + struct amdtp_stream *stream) |
---|
30 | 30 | { |
---|
| 31 | + struct fw_iso_resources *resources; |
---|
| 32 | + struct snd_motu_packet_format *packet_format; |
---|
31 | 33 | unsigned int midi_ports = 0; |
---|
| 34 | + int err; |
---|
| 35 | + |
---|
| 36 | + if (stream == &motu->rx_stream) { |
---|
| 37 | + resources = &motu->rx_resources; |
---|
| 38 | + packet_format = &motu->rx_packet_formats; |
---|
| 39 | + |
---|
| 40 | + if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || |
---|
| 41 | + (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) |
---|
| 42 | + midi_ports = 1; |
---|
| 43 | + } else { |
---|
| 44 | + resources = &motu->tx_resources; |
---|
| 45 | + packet_format = &motu->tx_packet_formats; |
---|
| 46 | + |
---|
| 47 | + if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || |
---|
| 48 | + (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) |
---|
| 49 | + midi_ports = 1; |
---|
| 50 | + } |
---|
| 51 | + |
---|
| 52 | + err = amdtp_motu_set_parameters(stream, rate, midi_ports, |
---|
| 53 | + packet_format); |
---|
| 54 | + if (err < 0) |
---|
| 55 | + return err; |
---|
| 56 | + |
---|
| 57 | + return fw_iso_resources_allocate(resources, |
---|
| 58 | + amdtp_stream_get_max_payload(stream), |
---|
| 59 | + fw_parent_device(motu->unit)->max_speed); |
---|
| 60 | +} |
---|
| 61 | + |
---|
| 62 | +static int begin_session(struct snd_motu *motu) |
---|
| 63 | +{ |
---|
32 | 64 | __be32 reg; |
---|
33 | 65 | u32 data; |
---|
34 | 66 | int err; |
---|
35 | 67 | |
---|
36 | | - if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || |
---|
37 | | - (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) |
---|
38 | | - midi_ports = 1; |
---|
39 | | - |
---|
40 | | - /* Set packet formation to our packet streaming engine. */ |
---|
41 | | - err = amdtp_motu_set_parameters(&motu->rx_stream, rate, midi_ports, |
---|
42 | | - &motu->rx_packet_formats); |
---|
43 | | - if (err < 0) |
---|
44 | | - return err; |
---|
45 | | - |
---|
46 | | - if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || |
---|
47 | | - (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) |
---|
48 | | - midi_ports = 1; |
---|
49 | | - else |
---|
50 | | - midi_ports = 0; |
---|
51 | | - |
---|
52 | | - err = amdtp_motu_set_parameters(&motu->tx_stream, rate, midi_ports, |
---|
53 | | - &motu->tx_packet_formats); |
---|
54 | | - if (err < 0) |
---|
55 | | - return err; |
---|
56 | | - |
---|
57 | | - /* Get isochronous resources on the bus. */ |
---|
58 | | - err = fw_iso_resources_allocate(&motu->rx_resources, |
---|
59 | | - amdtp_stream_get_max_payload(&motu->rx_stream), |
---|
60 | | - fw_parent_device(motu->unit)->max_speed); |
---|
61 | | - if (err < 0) |
---|
62 | | - return err; |
---|
63 | | - |
---|
64 | | - err = fw_iso_resources_allocate(&motu->tx_resources, |
---|
65 | | - amdtp_stream_get_max_payload(&motu->tx_stream), |
---|
66 | | - fw_parent_device(motu->unit)->max_speed); |
---|
67 | | - if (err < 0) |
---|
68 | | - return err; |
---|
69 | | - |
---|
70 | | - /* Configure the unit to start isochronous communication. */ |
---|
| 68 | + // Configure the unit to start isochronous communication. |
---|
71 | 69 | err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, ®, |
---|
72 | 70 | sizeof(reg)); |
---|
73 | 71 | if (err < 0) |
---|
.. | .. |
---|
84 | 82 | sizeof(reg)); |
---|
85 | 83 | } |
---|
86 | 84 | |
---|
87 | | -static void stop_both_streams(struct snd_motu *motu) |
---|
| 85 | +static void finish_session(struct snd_motu *motu) |
---|
88 | 86 | { |
---|
89 | 87 | __be32 reg; |
---|
90 | 88 | u32 data; |
---|
91 | 89 | int err; |
---|
92 | 90 | |
---|
93 | | - err = motu->spec->protocol->switch_fetching_mode(motu, false); |
---|
| 91 | + err = snd_motu_protocol_switch_fetching_mode(motu, false); |
---|
94 | 92 | if (err < 0) |
---|
95 | 93 | return; |
---|
96 | 94 | |
---|
.. | .. |
---|
106 | 104 | reg = cpu_to_be32(data); |
---|
107 | 105 | snd_motu_transaction_write(motu, ISOC_COMM_CONTROL_OFFSET, ®, |
---|
108 | 106 | sizeof(reg)); |
---|
109 | | - |
---|
110 | | - fw_iso_resources_free(&motu->tx_resources); |
---|
111 | | - fw_iso_resources_free(&motu->rx_resources); |
---|
112 | | -} |
---|
113 | | - |
---|
114 | | -static int start_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) |
---|
115 | | -{ |
---|
116 | | - struct fw_iso_resources *resources; |
---|
117 | | - int err; |
---|
118 | | - |
---|
119 | | - if (stream == &motu->rx_stream) |
---|
120 | | - resources = &motu->rx_resources; |
---|
121 | | - else |
---|
122 | | - resources = &motu->tx_resources; |
---|
123 | | - |
---|
124 | | - err = amdtp_stream_start(stream, resources->channel, |
---|
125 | | - fw_parent_device(motu->unit)->max_speed); |
---|
126 | | - if (err < 0) |
---|
127 | | - return err; |
---|
128 | | - |
---|
129 | | - if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) { |
---|
130 | | - amdtp_stream_stop(stream); |
---|
131 | | - fw_iso_resources_free(resources); |
---|
132 | | - return -ETIMEDOUT; |
---|
133 | | - } |
---|
134 | | - |
---|
135 | | - return 0; |
---|
136 | | -} |
---|
137 | | - |
---|
138 | | -static void stop_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) |
---|
139 | | -{ |
---|
140 | | - struct fw_iso_resources *resources; |
---|
141 | | - |
---|
142 | | - if (stream == &motu->rx_stream) |
---|
143 | | - resources = &motu->rx_resources; |
---|
144 | | - else |
---|
145 | | - resources = &motu->tx_resources; |
---|
146 | | - |
---|
147 | | - amdtp_stream_stop(stream); |
---|
148 | | - fw_iso_resources_free(resources); |
---|
149 | 107 | } |
---|
150 | 108 | |
---|
151 | 109 | int snd_motu_stream_cache_packet_formats(struct snd_motu *motu) |
---|
152 | 110 | { |
---|
153 | 111 | int err; |
---|
154 | 112 | |
---|
155 | | - err = motu->spec->protocol->cache_packet_formats(motu); |
---|
| 113 | + err = snd_motu_protocol_cache_packet_formats(motu); |
---|
156 | 114 | if (err < 0) |
---|
157 | 115 | return err; |
---|
158 | 116 | |
---|
.. | .. |
---|
175 | 133 | return 0; |
---|
176 | 134 | } |
---|
177 | 135 | |
---|
| 136 | +int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate, |
---|
| 137 | + unsigned int frames_per_period, |
---|
| 138 | + unsigned int frames_per_buffer) |
---|
| 139 | +{ |
---|
| 140 | + unsigned int curr_rate; |
---|
| 141 | + int err; |
---|
| 142 | + |
---|
| 143 | + err = snd_motu_protocol_get_clock_rate(motu, &curr_rate); |
---|
| 144 | + if (err < 0) |
---|
| 145 | + return err; |
---|
| 146 | + if (rate == 0) |
---|
| 147 | + rate = curr_rate; |
---|
| 148 | + |
---|
| 149 | + if (motu->substreams_counter == 0 || curr_rate != rate) { |
---|
| 150 | + amdtp_domain_stop(&motu->domain); |
---|
| 151 | + finish_session(motu); |
---|
| 152 | + |
---|
| 153 | + fw_iso_resources_free(&motu->tx_resources); |
---|
| 154 | + fw_iso_resources_free(&motu->rx_resources); |
---|
| 155 | + |
---|
| 156 | + err = snd_motu_protocol_set_clock_rate(motu, rate); |
---|
| 157 | + if (err < 0) { |
---|
| 158 | + dev_err(&motu->unit->device, |
---|
| 159 | + "fail to set sampling rate: %d\n", err); |
---|
| 160 | + return err; |
---|
| 161 | + } |
---|
| 162 | + |
---|
| 163 | + err = snd_motu_stream_cache_packet_formats(motu); |
---|
| 164 | + if (err < 0) |
---|
| 165 | + return err; |
---|
| 166 | + |
---|
| 167 | + err = keep_resources(motu, rate, &motu->tx_stream); |
---|
| 168 | + if (err < 0) |
---|
| 169 | + return err; |
---|
| 170 | + |
---|
| 171 | + err = keep_resources(motu, rate, &motu->rx_stream); |
---|
| 172 | + if (err < 0) { |
---|
| 173 | + fw_iso_resources_free(&motu->tx_resources); |
---|
| 174 | + return err; |
---|
| 175 | + } |
---|
| 176 | + |
---|
| 177 | + err = amdtp_domain_set_events_per_period(&motu->domain, |
---|
| 178 | + frames_per_period, frames_per_buffer); |
---|
| 179 | + if (err < 0) { |
---|
| 180 | + fw_iso_resources_free(&motu->tx_resources); |
---|
| 181 | + fw_iso_resources_free(&motu->rx_resources); |
---|
| 182 | + return err; |
---|
| 183 | + } |
---|
| 184 | + } |
---|
| 185 | + |
---|
| 186 | + return 0; |
---|
| 187 | +} |
---|
| 188 | + |
---|
178 | 189 | static int ensure_packet_formats(struct snd_motu *motu) |
---|
179 | 190 | { |
---|
180 | 191 | __be32 reg; |
---|
.. | .. |
---|
190 | 201 | data &= ~(TX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS | |
---|
191 | 202 | RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS| |
---|
192 | 203 | TX_PACKET_TRANSMISSION_SPEED_MASK); |
---|
193 | | - if (motu->tx_packet_formats.differed_part_pcm_chunks[0] == 0) |
---|
| 204 | + if (motu->spec->tx_fixed_pcm_chunks[0] == motu->tx_packet_formats.pcm_chunks[0]) |
---|
194 | 205 | data |= TX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS; |
---|
195 | | - if (motu->rx_packet_formats.differed_part_pcm_chunks[0] == 0) |
---|
| 206 | + if (motu->spec->rx_fixed_pcm_chunks[0] == motu->rx_packet_formats.pcm_chunks[0]) |
---|
196 | 207 | data |= RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS; |
---|
197 | 208 | data |= fw_parent_device(motu->unit)->max_speed; |
---|
198 | 209 | |
---|
.. | .. |
---|
201 | 212 | sizeof(reg)); |
---|
202 | 213 | } |
---|
203 | 214 | |
---|
204 | | -int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) |
---|
| 215 | +int snd_motu_stream_start_duplex(struct snd_motu *motu) |
---|
205 | 216 | { |
---|
206 | | - const struct snd_motu_protocol *protocol = motu->spec->protocol; |
---|
207 | | - unsigned int curr_rate; |
---|
| 217 | + unsigned int generation = motu->rx_resources.generation; |
---|
208 | 218 | int err = 0; |
---|
209 | 219 | |
---|
210 | | - if (motu->capture_substreams == 0 && motu->playback_substreams == 0) |
---|
| 220 | + if (motu->substreams_counter == 0) |
---|
211 | 221 | return 0; |
---|
212 | 222 | |
---|
213 | | - /* Some packet queueing errors. */ |
---|
214 | 223 | if (amdtp_streaming_error(&motu->rx_stream) || |
---|
215 | 224 | amdtp_streaming_error(&motu->tx_stream)) { |
---|
216 | | - amdtp_stream_stop(&motu->rx_stream); |
---|
217 | | - amdtp_stream_stop(&motu->tx_stream); |
---|
218 | | - stop_both_streams(motu); |
---|
| 225 | + amdtp_domain_stop(&motu->domain); |
---|
| 226 | + finish_session(motu); |
---|
219 | 227 | } |
---|
220 | 228 | |
---|
221 | | - err = snd_motu_stream_cache_packet_formats(motu); |
---|
222 | | - if (err < 0) |
---|
223 | | - return err; |
---|
| 229 | + if (generation != fw_parent_device(motu->unit)->card->generation) { |
---|
| 230 | + err = fw_iso_resources_update(&motu->rx_resources); |
---|
| 231 | + if (err < 0) |
---|
| 232 | + return err; |
---|
224 | 233 | |
---|
225 | | - /* Stop stream if rate is different. */ |
---|
226 | | - err = protocol->get_clock_rate(motu, &curr_rate); |
---|
227 | | - if (err < 0) { |
---|
228 | | - dev_err(&motu->unit->device, |
---|
229 | | - "fail to get sampling rate: %d\n", err); |
---|
230 | | - return err; |
---|
231 | | - } |
---|
232 | | - if (rate == 0) |
---|
233 | | - rate = curr_rate; |
---|
234 | | - if (rate != curr_rate) { |
---|
235 | | - amdtp_stream_stop(&motu->rx_stream); |
---|
236 | | - amdtp_stream_stop(&motu->tx_stream); |
---|
237 | | - stop_both_streams(motu); |
---|
| 234 | + err = fw_iso_resources_update(&motu->tx_resources); |
---|
| 235 | + if (err < 0) |
---|
| 236 | + return err; |
---|
238 | 237 | } |
---|
239 | 238 | |
---|
240 | 239 | if (!amdtp_stream_running(&motu->rx_stream)) { |
---|
241 | | - err = protocol->set_clock_rate(motu, rate); |
---|
242 | | - if (err < 0) { |
---|
243 | | - dev_err(&motu->unit->device, |
---|
244 | | - "fail to set sampling rate: %d\n", err); |
---|
245 | | - return err; |
---|
246 | | - } |
---|
| 240 | + int spd = fw_parent_device(motu->unit)->max_speed; |
---|
247 | 241 | |
---|
248 | 242 | err = ensure_packet_formats(motu); |
---|
249 | 243 | if (err < 0) |
---|
250 | 244 | return err; |
---|
251 | 245 | |
---|
252 | | - err = start_both_streams(motu, rate); |
---|
| 246 | + err = begin_session(motu); |
---|
253 | 247 | if (err < 0) { |
---|
254 | 248 | dev_err(&motu->unit->device, |
---|
255 | 249 | "fail to start isochronous comm: %d\n", err); |
---|
256 | 250 | goto stop_streams; |
---|
257 | 251 | } |
---|
258 | 252 | |
---|
259 | | - err = start_isoc_ctx(motu, &motu->rx_stream); |
---|
260 | | - if (err < 0) { |
---|
261 | | - dev_err(&motu->unit->device, |
---|
262 | | - "fail to start IT context: %d\n", err); |
---|
| 253 | + err = amdtp_domain_add_stream(&motu->domain, &motu->tx_stream, |
---|
| 254 | + motu->tx_resources.channel, spd); |
---|
| 255 | + if (err < 0) |
---|
| 256 | + goto stop_streams; |
---|
| 257 | + |
---|
| 258 | + err = amdtp_domain_add_stream(&motu->domain, &motu->rx_stream, |
---|
| 259 | + motu->rx_resources.channel, spd); |
---|
| 260 | + if (err < 0) |
---|
| 261 | + goto stop_streams; |
---|
| 262 | + |
---|
| 263 | + err = amdtp_domain_start(&motu->domain, 0); |
---|
| 264 | + if (err < 0) |
---|
| 265 | + goto stop_streams; |
---|
| 266 | + |
---|
| 267 | + if (!amdtp_stream_wait_callback(&motu->tx_stream, |
---|
| 268 | + CALLBACK_TIMEOUT) || |
---|
| 269 | + !amdtp_stream_wait_callback(&motu->rx_stream, |
---|
| 270 | + CALLBACK_TIMEOUT)) { |
---|
| 271 | + err = -ETIMEDOUT; |
---|
263 | 272 | goto stop_streams; |
---|
264 | 273 | } |
---|
265 | 274 | |
---|
266 | | - err = protocol->switch_fetching_mode(motu, true); |
---|
| 275 | + err = snd_motu_protocol_switch_fetching_mode(motu, true); |
---|
267 | 276 | if (err < 0) { |
---|
268 | 277 | dev_err(&motu->unit->device, |
---|
269 | 278 | "fail to enable frame fetching: %d\n", err); |
---|
.. | .. |
---|
271 | 280 | } |
---|
272 | 281 | } |
---|
273 | 282 | |
---|
274 | | - if (!amdtp_stream_running(&motu->tx_stream) && |
---|
275 | | - motu->capture_substreams > 0) { |
---|
276 | | - err = start_isoc_ctx(motu, &motu->tx_stream); |
---|
277 | | - if (err < 0) { |
---|
278 | | - dev_err(&motu->unit->device, |
---|
279 | | - "fail to start IR context: %d", err); |
---|
280 | | - amdtp_stream_stop(&motu->rx_stream); |
---|
281 | | - goto stop_streams; |
---|
282 | | - } |
---|
283 | | - } |
---|
284 | | - |
---|
285 | 283 | return 0; |
---|
286 | 284 | |
---|
287 | 285 | stop_streams: |
---|
288 | | - stop_both_streams(motu); |
---|
| 286 | + amdtp_domain_stop(&motu->domain); |
---|
| 287 | + finish_session(motu); |
---|
289 | 288 | return err; |
---|
290 | 289 | } |
---|
291 | 290 | |
---|
292 | 291 | void snd_motu_stream_stop_duplex(struct snd_motu *motu) |
---|
293 | 292 | { |
---|
294 | | - if (motu->capture_substreams == 0) { |
---|
295 | | - if (amdtp_stream_running(&motu->tx_stream)) |
---|
296 | | - stop_isoc_ctx(motu, &motu->tx_stream); |
---|
| 293 | + if (motu->substreams_counter == 0) { |
---|
| 294 | + amdtp_domain_stop(&motu->domain); |
---|
| 295 | + finish_session(motu); |
---|
297 | 296 | |
---|
298 | | - if (motu->playback_substreams == 0) { |
---|
299 | | - if (amdtp_stream_running(&motu->rx_stream)) |
---|
300 | | - stop_isoc_ctx(motu, &motu->rx_stream); |
---|
301 | | - stop_both_streams(motu); |
---|
302 | | - } |
---|
| 297 | + fw_iso_resources_free(&motu->tx_resources); |
---|
| 298 | + fw_iso_resources_free(&motu->rx_resources); |
---|
303 | 299 | } |
---|
304 | 300 | } |
---|
305 | 301 | |
---|
306 | | -static int init_stream(struct snd_motu *motu, enum amdtp_stream_direction dir) |
---|
| 302 | +static int init_stream(struct snd_motu *motu, struct amdtp_stream *s) |
---|
307 | 303 | { |
---|
308 | | - int err; |
---|
309 | | - struct amdtp_stream *stream; |
---|
310 | 304 | struct fw_iso_resources *resources; |
---|
| 305 | + enum amdtp_stream_direction dir; |
---|
| 306 | + int err; |
---|
311 | 307 | |
---|
312 | | - if (dir == AMDTP_IN_STREAM) { |
---|
313 | | - stream = &motu->tx_stream; |
---|
| 308 | + if (s == &motu->tx_stream) { |
---|
314 | 309 | resources = &motu->tx_resources; |
---|
| 310 | + dir = AMDTP_IN_STREAM; |
---|
315 | 311 | } else { |
---|
316 | | - stream = &motu->rx_stream; |
---|
317 | 312 | resources = &motu->rx_resources; |
---|
| 313 | + dir = AMDTP_OUT_STREAM; |
---|
318 | 314 | } |
---|
319 | 315 | |
---|
320 | 316 | err = fw_iso_resources_init(resources, motu->unit); |
---|
321 | 317 | if (err < 0) |
---|
322 | 318 | return err; |
---|
323 | 319 | |
---|
324 | | - err = amdtp_motu_init(stream, motu->unit, dir, motu->spec->protocol); |
---|
325 | | - if (err < 0) { |
---|
326 | | - amdtp_stream_destroy(stream); |
---|
| 320 | + err = amdtp_motu_init(s, motu->unit, dir, motu->spec); |
---|
| 321 | + if (err < 0) |
---|
327 | 322 | fw_iso_resources_destroy(resources); |
---|
328 | | - } |
---|
329 | 323 | |
---|
330 | 324 | return err; |
---|
331 | 325 | } |
---|
332 | 326 | |
---|
333 | | -static void destroy_stream(struct snd_motu *motu, |
---|
334 | | - enum amdtp_stream_direction dir) |
---|
| 327 | +static void destroy_stream(struct snd_motu *motu, struct amdtp_stream *s) |
---|
335 | 328 | { |
---|
336 | | - struct amdtp_stream *stream; |
---|
337 | | - struct fw_iso_resources *resources; |
---|
| 329 | + amdtp_stream_destroy(s); |
---|
338 | 330 | |
---|
339 | | - if (dir == AMDTP_IN_STREAM) { |
---|
340 | | - stream = &motu->tx_stream; |
---|
341 | | - resources = &motu->tx_resources; |
---|
342 | | - } else { |
---|
343 | | - stream = &motu->rx_stream; |
---|
344 | | - resources = &motu->rx_resources; |
---|
345 | | - } |
---|
346 | | - |
---|
347 | | - amdtp_stream_destroy(stream); |
---|
348 | | - fw_iso_resources_destroy(resources); |
---|
| 331 | + if (s == &motu->tx_stream) |
---|
| 332 | + fw_iso_resources_destroy(&motu->tx_resources); |
---|
| 333 | + else |
---|
| 334 | + fw_iso_resources_destroy(&motu->rx_resources); |
---|
349 | 335 | } |
---|
350 | 336 | |
---|
351 | 337 | int snd_motu_stream_init_duplex(struct snd_motu *motu) |
---|
352 | 338 | { |
---|
353 | 339 | int err; |
---|
354 | 340 | |
---|
355 | | - err = init_stream(motu, AMDTP_IN_STREAM); |
---|
| 341 | + err = init_stream(motu, &motu->tx_stream); |
---|
356 | 342 | if (err < 0) |
---|
357 | 343 | return err; |
---|
358 | 344 | |
---|
359 | | - err = init_stream(motu, AMDTP_OUT_STREAM); |
---|
360 | | - if (err < 0) |
---|
361 | | - destroy_stream(motu, AMDTP_IN_STREAM); |
---|
| 345 | + err = init_stream(motu, &motu->rx_stream); |
---|
| 346 | + if (err < 0) { |
---|
| 347 | + destroy_stream(motu, &motu->tx_stream); |
---|
| 348 | + return err; |
---|
| 349 | + } |
---|
| 350 | + |
---|
| 351 | + err = amdtp_domain_init(&motu->domain); |
---|
| 352 | + if (err < 0) { |
---|
| 353 | + destroy_stream(motu, &motu->tx_stream); |
---|
| 354 | + destroy_stream(motu, &motu->rx_stream); |
---|
| 355 | + } |
---|
362 | 356 | |
---|
363 | 357 | return err; |
---|
364 | 358 | } |
---|
365 | 359 | |
---|
366 | | -/* |
---|
367 | | - * This function should be called before starting streams or after stopping |
---|
368 | | - * streams. |
---|
369 | | - */ |
---|
| 360 | +// This function should be called before starting streams or after stopping |
---|
| 361 | +// streams. |
---|
370 | 362 | void snd_motu_stream_destroy_duplex(struct snd_motu *motu) |
---|
371 | 363 | { |
---|
372 | | - destroy_stream(motu, AMDTP_IN_STREAM); |
---|
373 | | - destroy_stream(motu, AMDTP_OUT_STREAM); |
---|
| 364 | + amdtp_domain_destroy(&motu->domain); |
---|
374 | 365 | |
---|
375 | | - motu->playback_substreams = 0; |
---|
376 | | - motu->capture_substreams = 0; |
---|
| 366 | + destroy_stream(motu, &motu->rx_stream); |
---|
| 367 | + destroy_stream(motu, &motu->tx_stream); |
---|
| 368 | + |
---|
| 369 | + motu->substreams_counter = 0; |
---|
377 | 370 | } |
---|
378 | 371 | |
---|
379 | 372 | static void motu_lock_changed(struct snd_motu *motu) |
---|