Lines Matching defs:efw
11 static int init_stream(struct snd_efw *efw, struct amdtp_stream *stream)
18 if (stream == &efw->tx_stream) {
19 conn = &efw->out_conn;
23 conn = &efw->in_conn;
28 err = cmp_connection_init(conn, efw->unit, c_dir, 0);
32 err = amdtp_am824_init(stream, efw->unit, s_dir, CIP_BLOCKING | CIP_UNAWARE_SYT);
39 if (stream == &efw->tx_stream) {
41 efw->tx_stream.flags |= CIP_EMPTY_WITH_TAG0;
43 efw->tx_stream.flags |= CIP_DBC_IS_END_EVENT;
45 efw->tx_stream.flags |= CIP_SKIP_DBC_ZERO_CHECK;
48 if (efw->is_fireworks3 &&
49 (efw->firmware_version == 0x5070000 ||
50 efw->firmware_version == 0x5070300 ||
51 efw->firmware_version == 0x5080000))
52 efw->tx_stream.flags |= CIP_UNALIGHED_DBC;
55 if (efw->is_af9 || efw->firmware_version == 0x4060000)
56 efw->tx_stream.flags |= CIP_WRONG_DBS;
58 if (efw->firmware_version == 0x5050000)
59 efw->tx_stream.ctx_data.tx.dbc_interval = 8;
65 static int start_stream(struct snd_efw *efw, struct amdtp_stream *stream,
71 if (stream == &efw->tx_stream)
72 conn = &efw->out_conn;
74 conn = &efw->in_conn;
82 err = amdtp_domain_add_stream(&efw->domain, stream,
94 static void destroy_stream(struct snd_efw *efw, struct amdtp_stream *stream)
98 if (stream == &efw->tx_stream)
99 cmp_connection_destroy(&efw->out_conn);
101 cmp_connection_destroy(&efw->in_conn);
105 check_connection_used_by_others(struct snd_efw *efw, struct amdtp_stream *s)
111 if (s == &efw->tx_stream)
112 conn = &efw->out_conn;
114 conn = &efw->in_conn;
118 dev_err(&efw->unit->device,
128 int snd_efw_stream_init_duplex(struct snd_efw *efw)
132 err = init_stream(efw, &efw->tx_stream);
136 err = init_stream(efw, &efw->rx_stream);
138 destroy_stream(efw, &efw->tx_stream);
142 err = amdtp_domain_init(&efw->domain);
144 destroy_stream(efw, &efw->tx_stream);
145 destroy_stream(efw, &efw->rx_stream);
150 err = snd_efw_command_set_tx_mode(efw, SND_EFW_TRANSPORT_MODE_IEC61883);
152 destroy_stream(efw, &efw->tx_stream);
153 destroy_stream(efw, &efw->rx_stream);
159 static int keep_resources(struct snd_efw *efw, struct amdtp_stream *stream,
167 if (stream == &efw->tx_stream) {
168 pcm_channels = efw->pcm_capture_channels[mode];
169 midi_ports = efw->midi_out_ports;
170 conn = &efw->out_conn;
172 pcm_channels = efw->pcm_playback_channels[mode];
173 midi_ports = efw->midi_in_ports;
174 conn = &efw->in_conn;
185 int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate,
194 err = check_connection_used_by_others(efw, &efw->rx_stream);
199 err = snd_efw_command_get_sampling_rate(efw, &curr_rate);
205 amdtp_domain_stop(&efw->domain);
207 cmp_connection_break(&efw->out_conn);
208 cmp_connection_break(&efw->in_conn);
210 cmp_connection_release(&efw->out_conn);
211 cmp_connection_release(&efw->in_conn);
214 if (efw->substreams_counter == 0 || rate != curr_rate) {
217 err = snd_efw_command_set_sampling_rate(efw, rate);
225 err = keep_resources(efw, &efw->tx_stream, rate, mode);
229 err = keep_resources(efw, &efw->rx_stream, rate, mode);
231 cmp_connection_release(&efw->in_conn);
235 err = amdtp_domain_set_events_per_period(&efw->domain,
238 cmp_connection_release(&efw->in_conn);
239 cmp_connection_release(&efw->out_conn);
247 int snd_efw_stream_start_duplex(struct snd_efw *efw)
253 if (efw->substreams_counter == 0)
256 if (amdtp_streaming_error(&efw->rx_stream) ||
257 amdtp_streaming_error(&efw->tx_stream)) {
258 amdtp_domain_stop(&efw->domain);
259 cmp_connection_break(&efw->out_conn);
260 cmp_connection_break(&efw->in_conn);
263 err = snd_efw_command_get_sampling_rate(efw, &rate);
267 if (!amdtp_stream_running(&efw->rx_stream)) {
272 if (efw->is_fireworks3 && !efw->is_af9)
277 err = start_stream(efw, &efw->rx_stream, rate);
281 err = start_stream(efw, &efw->tx_stream, rate);
288 err = amdtp_domain_start(&efw->domain, tx_init_skip_cycles, true, false);
292 if (!amdtp_domain_wait_ready(&efw->domain, READY_TIMEOUT_MS)) {
300 amdtp_domain_stop(&efw->domain);
302 cmp_connection_break(&efw->out_conn);
303 cmp_connection_break(&efw->in_conn);
308 void snd_efw_stream_stop_duplex(struct snd_efw *efw)
310 if (efw->substreams_counter == 0) {
311 amdtp_domain_stop(&efw->domain);
313 cmp_connection_break(&efw->out_conn);
314 cmp_connection_break(&efw->in_conn);
316 cmp_connection_release(&efw->out_conn);
317 cmp_connection_release(&efw->in_conn);
321 void snd_efw_stream_update_duplex(struct snd_efw *efw)
323 amdtp_domain_stop(&efw->domain);
325 cmp_connection_break(&efw->out_conn);
326 cmp_connection_break(&efw->in_conn);
328 amdtp_stream_pcm_abort(&efw->rx_stream);
329 amdtp_stream_pcm_abort(&efw->tx_stream);
332 void snd_efw_stream_destroy_duplex(struct snd_efw *efw)
334 amdtp_domain_destroy(&efw->domain);
336 destroy_stream(efw, &efw->rx_stream);
337 destroy_stream(efw, &efw->tx_stream);
340 void snd_efw_stream_lock_changed(struct snd_efw *efw)
342 efw->dev_lock_changed = true;
343 wake_up(&efw->hwdep_wait);
346 int snd_efw_stream_lock_try(struct snd_efw *efw)
348 guard(spinlock_irq)(&efw->lock);
351 if (efw->dev_lock_count < 0)
355 if (efw->dev_lock_count++ == 0)
356 snd_efw_stream_lock_changed(efw);
360 void snd_efw_stream_lock_release(struct snd_efw *efw)
362 guard(spinlock_irq)(&efw->lock);
364 if (WARN_ON(efw->dev_lock_count <= 0))
366 if (--efw->dev_lock_count == 0)
367 snd_efw_stream_lock_changed(efw);