• Home
  • Raw
  • Download

Lines Matching refs:motu

28 static int keep_resources(struct snd_motu *motu, unsigned int rate,  in keep_resources()  argument
36 if (stream == &motu->rx_stream) { in keep_resources()
37 resources = &motu->rx_resources; in keep_resources()
38 packet_format = &motu->rx_packet_formats; in keep_resources()
40 if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || in keep_resources()
41 (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) in keep_resources()
44 resources = &motu->tx_resources; in keep_resources()
45 packet_format = &motu->tx_packet_formats; in keep_resources()
47 if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || in keep_resources()
48 (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) in keep_resources()
59 fw_parent_device(motu->unit)->max_speed); in keep_resources()
62 static int begin_session(struct snd_motu *motu) in begin_session() argument
69 err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, &reg, in begin_session()
76 (motu->rx_resources.channel << RX_ISOC_COMM_CHANNEL_SHIFT) | in begin_session()
78 (motu->tx_resources.channel << TX_ISOC_COMM_CHANNEL_SHIFT); in begin_session()
81 return snd_motu_transaction_write(motu, ISOC_COMM_CONTROL_OFFSET, &reg, in begin_session()
85 static void finish_session(struct snd_motu *motu) in finish_session() argument
91 err = snd_motu_protocol_switch_fetching_mode(motu, false); in finish_session()
95 err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, &reg, in finish_session()
105 snd_motu_transaction_write(motu, ISOC_COMM_CONTROL_OFFSET, &reg, in finish_session()
109 int snd_motu_stream_cache_packet_formats(struct snd_motu *motu) in snd_motu_stream_cache_packet_formats() argument
113 err = snd_motu_protocol_cache_packet_formats(motu); in snd_motu_stream_cache_packet_formats()
117 if (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) { in snd_motu_stream_cache_packet_formats()
118 motu->tx_packet_formats.midi_flag_offset = 4; in snd_motu_stream_cache_packet_formats()
119 motu->tx_packet_formats.midi_byte_offset = 6; in snd_motu_stream_cache_packet_formats()
120 } else if (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q) { in snd_motu_stream_cache_packet_formats()
121 motu->tx_packet_formats.midi_flag_offset = 8; in snd_motu_stream_cache_packet_formats()
122 motu->tx_packet_formats.midi_byte_offset = 7; in snd_motu_stream_cache_packet_formats()
125 if (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) { in snd_motu_stream_cache_packet_formats()
126 motu->rx_packet_formats.midi_flag_offset = 4; in snd_motu_stream_cache_packet_formats()
127 motu->rx_packet_formats.midi_byte_offset = 6; in snd_motu_stream_cache_packet_formats()
128 } else if (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q) { in snd_motu_stream_cache_packet_formats()
129 motu->rx_packet_formats.midi_flag_offset = 8; in snd_motu_stream_cache_packet_formats()
130 motu->rx_packet_formats.midi_byte_offset = 7; in snd_motu_stream_cache_packet_formats()
136 int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate, in snd_motu_stream_reserve_duplex() argument
143 err = snd_motu_protocol_get_clock_rate(motu, &curr_rate); in snd_motu_stream_reserve_duplex()
149 if (motu->substreams_counter == 0 || curr_rate != rate) { in snd_motu_stream_reserve_duplex()
150 amdtp_domain_stop(&motu->domain); in snd_motu_stream_reserve_duplex()
151 finish_session(motu); in snd_motu_stream_reserve_duplex()
153 fw_iso_resources_free(&motu->tx_resources); in snd_motu_stream_reserve_duplex()
154 fw_iso_resources_free(&motu->rx_resources); in snd_motu_stream_reserve_duplex()
156 err = snd_motu_protocol_set_clock_rate(motu, rate); in snd_motu_stream_reserve_duplex()
158 dev_err(&motu->unit->device, in snd_motu_stream_reserve_duplex()
163 err = snd_motu_stream_cache_packet_formats(motu); in snd_motu_stream_reserve_duplex()
167 err = keep_resources(motu, rate, &motu->tx_stream); in snd_motu_stream_reserve_duplex()
171 err = keep_resources(motu, rate, &motu->rx_stream); in snd_motu_stream_reserve_duplex()
173 fw_iso_resources_free(&motu->tx_resources); in snd_motu_stream_reserve_duplex()
177 err = amdtp_domain_set_events_per_period(&motu->domain, in snd_motu_stream_reserve_duplex()
180 fw_iso_resources_free(&motu->tx_resources); in snd_motu_stream_reserve_duplex()
181 fw_iso_resources_free(&motu->rx_resources); in snd_motu_stream_reserve_duplex()
189 static int ensure_packet_formats(struct snd_motu *motu) in ensure_packet_formats() argument
195 err = snd_motu_transaction_read(motu, PACKET_FORMAT_OFFSET, &reg, in ensure_packet_formats()
204 if (motu->spec->tx_fixed_pcm_chunks[0] == motu->tx_packet_formats.pcm_chunks[0]) in ensure_packet_formats()
206 if (motu->spec->rx_fixed_pcm_chunks[0] == motu->rx_packet_formats.pcm_chunks[0]) in ensure_packet_formats()
208 data |= fw_parent_device(motu->unit)->max_speed; in ensure_packet_formats()
211 return snd_motu_transaction_write(motu, PACKET_FORMAT_OFFSET, &reg, in ensure_packet_formats()
215 int snd_motu_stream_start_duplex(struct snd_motu *motu) in snd_motu_stream_start_duplex() argument
217 unsigned int generation = motu->rx_resources.generation; in snd_motu_stream_start_duplex()
220 if (motu->substreams_counter == 0) in snd_motu_stream_start_duplex()
223 if (amdtp_streaming_error(&motu->rx_stream) || in snd_motu_stream_start_duplex()
224 amdtp_streaming_error(&motu->tx_stream)) { in snd_motu_stream_start_duplex()
225 amdtp_domain_stop(&motu->domain); in snd_motu_stream_start_duplex()
226 finish_session(motu); in snd_motu_stream_start_duplex()
229 if (generation != fw_parent_device(motu->unit)->card->generation) { in snd_motu_stream_start_duplex()
230 err = fw_iso_resources_update(&motu->rx_resources); in snd_motu_stream_start_duplex()
234 err = fw_iso_resources_update(&motu->tx_resources); in snd_motu_stream_start_duplex()
239 if (!amdtp_stream_running(&motu->rx_stream)) { in snd_motu_stream_start_duplex()
240 int spd = fw_parent_device(motu->unit)->max_speed; in snd_motu_stream_start_duplex()
242 err = ensure_packet_formats(motu); in snd_motu_stream_start_duplex()
246 err = begin_session(motu); in snd_motu_stream_start_duplex()
248 dev_err(&motu->unit->device, in snd_motu_stream_start_duplex()
253 err = amdtp_domain_add_stream(&motu->domain, &motu->tx_stream, in snd_motu_stream_start_duplex()
254 motu->tx_resources.channel, spd); in snd_motu_stream_start_duplex()
258 err = amdtp_domain_add_stream(&motu->domain, &motu->rx_stream, in snd_motu_stream_start_duplex()
259 motu->rx_resources.channel, spd); in snd_motu_stream_start_duplex()
263 err = amdtp_domain_start(&motu->domain, 0); in snd_motu_stream_start_duplex()
267 if (!amdtp_stream_wait_callback(&motu->tx_stream, in snd_motu_stream_start_duplex()
269 !amdtp_stream_wait_callback(&motu->rx_stream, in snd_motu_stream_start_duplex()
275 err = snd_motu_protocol_switch_fetching_mode(motu, true); in snd_motu_stream_start_duplex()
277 dev_err(&motu->unit->device, in snd_motu_stream_start_duplex()
286 amdtp_domain_stop(&motu->domain); in snd_motu_stream_start_duplex()
287 finish_session(motu); in snd_motu_stream_start_duplex()
291 void snd_motu_stream_stop_duplex(struct snd_motu *motu) in snd_motu_stream_stop_duplex() argument
293 if (motu->substreams_counter == 0) { in snd_motu_stream_stop_duplex()
294 amdtp_domain_stop(&motu->domain); in snd_motu_stream_stop_duplex()
295 finish_session(motu); in snd_motu_stream_stop_duplex()
297 fw_iso_resources_free(&motu->tx_resources); in snd_motu_stream_stop_duplex()
298 fw_iso_resources_free(&motu->rx_resources); in snd_motu_stream_stop_duplex()
302 static int init_stream(struct snd_motu *motu, struct amdtp_stream *s) in init_stream() argument
308 if (s == &motu->tx_stream) { in init_stream()
309 resources = &motu->tx_resources; in init_stream()
312 resources = &motu->rx_resources; in init_stream()
316 err = fw_iso_resources_init(resources, motu->unit); in init_stream()
320 err = amdtp_motu_init(s, motu->unit, dir, motu->spec); in init_stream()
327 static void destroy_stream(struct snd_motu *motu, struct amdtp_stream *s) in destroy_stream() argument
331 if (s == &motu->tx_stream) in destroy_stream()
332 fw_iso_resources_destroy(&motu->tx_resources); in destroy_stream()
334 fw_iso_resources_destroy(&motu->rx_resources); in destroy_stream()
337 int snd_motu_stream_init_duplex(struct snd_motu *motu) in snd_motu_stream_init_duplex() argument
341 err = init_stream(motu, &motu->tx_stream); in snd_motu_stream_init_duplex()
345 err = init_stream(motu, &motu->rx_stream); in snd_motu_stream_init_duplex()
347 destroy_stream(motu, &motu->tx_stream); in snd_motu_stream_init_duplex()
351 err = amdtp_domain_init(&motu->domain); in snd_motu_stream_init_duplex()
353 destroy_stream(motu, &motu->tx_stream); in snd_motu_stream_init_duplex()
354 destroy_stream(motu, &motu->rx_stream); in snd_motu_stream_init_duplex()
362 void snd_motu_stream_destroy_duplex(struct snd_motu *motu) in snd_motu_stream_destroy_duplex() argument
364 amdtp_domain_destroy(&motu->domain); in snd_motu_stream_destroy_duplex()
366 destroy_stream(motu, &motu->rx_stream); in snd_motu_stream_destroy_duplex()
367 destroy_stream(motu, &motu->tx_stream); in snd_motu_stream_destroy_duplex()
369 motu->substreams_counter = 0; in snd_motu_stream_destroy_duplex()
372 static void motu_lock_changed(struct snd_motu *motu) in motu_lock_changed() argument
374 motu->dev_lock_changed = true; in motu_lock_changed()
375 wake_up(&motu->hwdep_wait); in motu_lock_changed()
378 int snd_motu_stream_lock_try(struct snd_motu *motu) in snd_motu_stream_lock_try() argument
382 spin_lock_irq(&motu->lock); in snd_motu_stream_lock_try()
384 if (motu->dev_lock_count < 0) { in snd_motu_stream_lock_try()
389 if (motu->dev_lock_count++ == 0) in snd_motu_stream_lock_try()
390 motu_lock_changed(motu); in snd_motu_stream_lock_try()
393 spin_unlock_irq(&motu->lock); in snd_motu_stream_lock_try()
397 void snd_motu_stream_lock_release(struct snd_motu *motu) in snd_motu_stream_lock_release() argument
399 spin_lock_irq(&motu->lock); in snd_motu_stream_lock_release()
401 if (WARN_ON(motu->dev_lock_count <= 0)) in snd_motu_stream_lock_release()
404 if (--motu->dev_lock_count == 0) in snd_motu_stream_lock_release()
405 motu_lock_changed(motu); in snd_motu_stream_lock_release()
407 spin_unlock_irq(&motu->lock); in snd_motu_stream_lock_release()