Lines Matching refs:ff
33 static inline void finish_session(struct snd_ff *ff) in finish_session() argument
35 ff->spec->protocol->finish_session(ff); in finish_session()
36 ff->spec->protocol->switch_fetching_mode(ff, false); in finish_session()
39 static int init_stream(struct snd_ff *ff, struct amdtp_stream *s) in init_stream() argument
45 if (s == &ff->tx_stream) { in init_stream()
46 resources = &ff->tx_resources; in init_stream()
49 resources = &ff->rx_resources; in init_stream()
53 err = fw_iso_resources_init(resources, ff->unit); in init_stream()
57 err = amdtp_ff_init(s, ff->unit, dir); in init_stream()
64 static void destroy_stream(struct snd_ff *ff, struct amdtp_stream *s) in destroy_stream() argument
68 if (s == &ff->tx_stream) in destroy_stream()
69 fw_iso_resources_destroy(&ff->tx_resources); in destroy_stream()
71 fw_iso_resources_destroy(&ff->rx_resources); in destroy_stream()
74 int snd_ff_stream_init_duplex(struct snd_ff *ff) in snd_ff_stream_init_duplex() argument
78 err = init_stream(ff, &ff->rx_stream); in snd_ff_stream_init_duplex()
82 err = init_stream(ff, &ff->tx_stream); in snd_ff_stream_init_duplex()
84 destroy_stream(ff, &ff->rx_stream); in snd_ff_stream_init_duplex()
88 err = amdtp_domain_init(&ff->domain); in snd_ff_stream_init_duplex()
90 destroy_stream(ff, &ff->rx_stream); in snd_ff_stream_init_duplex()
91 destroy_stream(ff, &ff->tx_stream); in snd_ff_stream_init_duplex()
101 void snd_ff_stream_destroy_duplex(struct snd_ff *ff) in snd_ff_stream_destroy_duplex() argument
103 amdtp_domain_destroy(&ff->domain); in snd_ff_stream_destroy_duplex()
105 destroy_stream(ff, &ff->rx_stream); in snd_ff_stream_destroy_duplex()
106 destroy_stream(ff, &ff->tx_stream); in snd_ff_stream_destroy_duplex()
109 int snd_ff_stream_reserve_duplex(struct snd_ff *ff, unsigned int rate, in snd_ff_stream_reserve_duplex() argument
117 err = ff->spec->protocol->get_clock(ff, &curr_rate, &src); in snd_ff_stream_reserve_duplex()
121 if (ff->substreams_counter == 0 || curr_rate != rate) { in snd_ff_stream_reserve_duplex()
125 amdtp_domain_stop(&ff->domain); in snd_ff_stream_reserve_duplex()
126 finish_session(ff); in snd_ff_stream_reserve_duplex()
128 fw_iso_resources_free(&ff->tx_resources); in snd_ff_stream_reserve_duplex()
129 fw_iso_resources_free(&ff->rx_resources); in snd_ff_stream_reserve_duplex()
142 err = amdtp_ff_set_parameters(&ff->tx_stream, rate, in snd_ff_stream_reserve_duplex()
143 ff->spec->pcm_capture_channels[mode]); in snd_ff_stream_reserve_duplex()
147 err = amdtp_ff_set_parameters(&ff->rx_stream, rate, in snd_ff_stream_reserve_duplex()
148 ff->spec->pcm_playback_channels[mode]); in snd_ff_stream_reserve_duplex()
152 err = ff->spec->protocol->allocate_resources(ff, rate); in snd_ff_stream_reserve_duplex()
156 err = amdtp_domain_set_events_per_period(&ff->domain, in snd_ff_stream_reserve_duplex()
159 fw_iso_resources_free(&ff->tx_resources); in snd_ff_stream_reserve_duplex()
160 fw_iso_resources_free(&ff->rx_resources); in snd_ff_stream_reserve_duplex()
168 int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate) in snd_ff_stream_start_duplex() argument
172 if (ff->substreams_counter == 0) in snd_ff_stream_start_duplex()
175 if (amdtp_streaming_error(&ff->tx_stream) || in snd_ff_stream_start_duplex()
176 amdtp_streaming_error(&ff->rx_stream)) { in snd_ff_stream_start_duplex()
177 amdtp_domain_stop(&ff->domain); in snd_ff_stream_start_duplex()
178 finish_session(ff); in snd_ff_stream_start_duplex()
185 if (!amdtp_stream_running(&ff->rx_stream)) { in snd_ff_stream_start_duplex()
186 int spd = fw_parent_device(ff->unit)->max_speed; in snd_ff_stream_start_duplex()
188 err = ff->spec->protocol->begin_session(ff, rate); in snd_ff_stream_start_duplex()
192 err = amdtp_domain_add_stream(&ff->domain, &ff->rx_stream, in snd_ff_stream_start_duplex()
193 ff->rx_resources.channel, spd); in snd_ff_stream_start_duplex()
197 err = amdtp_domain_add_stream(&ff->domain, &ff->tx_stream, in snd_ff_stream_start_duplex()
198 ff->tx_resources.channel, spd); in snd_ff_stream_start_duplex()
206 err = amdtp_domain_start(&ff->domain, 0, true, true); in snd_ff_stream_start_duplex()
210 if (!amdtp_domain_wait_ready(&ff->domain, READY_TIMEOUT_MS)) { in snd_ff_stream_start_duplex()
215 err = ff->spec->protocol->switch_fetching_mode(ff, true); in snd_ff_stream_start_duplex()
222 amdtp_domain_stop(&ff->domain); in snd_ff_stream_start_duplex()
223 finish_session(ff); in snd_ff_stream_start_duplex()
228 void snd_ff_stream_stop_duplex(struct snd_ff *ff) in snd_ff_stream_stop_duplex() argument
230 if (ff->substreams_counter == 0) { in snd_ff_stream_stop_duplex()
231 amdtp_domain_stop(&ff->domain); in snd_ff_stream_stop_duplex()
232 finish_session(ff); in snd_ff_stream_stop_duplex()
234 fw_iso_resources_free(&ff->tx_resources); in snd_ff_stream_stop_duplex()
235 fw_iso_resources_free(&ff->rx_resources); in snd_ff_stream_stop_duplex()
239 void snd_ff_stream_update_duplex(struct snd_ff *ff) in snd_ff_stream_update_duplex() argument
241 amdtp_domain_stop(&ff->domain); in snd_ff_stream_update_duplex()
244 amdtp_stream_pcm_abort(&ff->tx_stream); in snd_ff_stream_update_duplex()
245 amdtp_stream_pcm_abort(&ff->rx_stream); in snd_ff_stream_update_duplex()
248 void snd_ff_stream_lock_changed(struct snd_ff *ff) in snd_ff_stream_lock_changed() argument
250 ff->dev_lock_changed = true; in snd_ff_stream_lock_changed()
251 wake_up(&ff->hwdep_wait); in snd_ff_stream_lock_changed()
254 int snd_ff_stream_lock_try(struct snd_ff *ff) in snd_ff_stream_lock_try() argument
258 spin_lock_irq(&ff->lock); in snd_ff_stream_lock_try()
261 if (ff->dev_lock_count < 0) { in snd_ff_stream_lock_try()
267 if (ff->dev_lock_count++ == 0) in snd_ff_stream_lock_try()
268 snd_ff_stream_lock_changed(ff); in snd_ff_stream_lock_try()
271 spin_unlock_irq(&ff->lock); in snd_ff_stream_lock_try()
275 void snd_ff_stream_lock_release(struct snd_ff *ff) in snd_ff_stream_lock_release() argument
277 spin_lock_irq(&ff->lock); in snd_ff_stream_lock_release()
279 if (WARN_ON(ff->dev_lock_count <= 0)) in snd_ff_stream_lock_release()
281 if (--ff->dev_lock_count == 0) in snd_ff_stream_lock_release()
282 snd_ff_stream_lock_changed(ff); in snd_ff_stream_lock_release()
284 spin_unlock_irq(&ff->lock); in snd_ff_stream_lock_release()