Lines Matching refs:ff

3  * ff-stream.c - a part of driver for RME Fireface series
8 #include "ff.h"
33 static inline void finish_session(struct snd_ff *ff)
35 ff->spec->protocol->finish_session(ff);
36 ff->spec->protocol->switch_fetching_mode(ff, false);
39 static int init_stream(struct snd_ff *ff, struct amdtp_stream *s)
45 if (s == &ff->tx_stream) {
46 resources = &ff->tx_resources;
49 resources = &ff->rx_resources;
53 err = fw_iso_resources_init(resources, ff->unit);
57 err = amdtp_ff_init(s, ff->unit, dir);
64 static void destroy_stream(struct snd_ff *ff, struct amdtp_stream *s)
68 if (s == &ff->tx_stream)
69 fw_iso_resources_destroy(&ff->tx_resources);
71 fw_iso_resources_destroy(&ff->rx_resources);
74 int snd_ff_stream_init_duplex(struct snd_ff *ff)
78 err = init_stream(ff, &ff->rx_stream);
82 err = init_stream(ff, &ff->tx_stream);
84 destroy_stream(ff, &ff->rx_stream);
88 err = amdtp_domain_init(&ff->domain);
90 destroy_stream(ff, &ff->rx_stream);
91 destroy_stream(ff, &ff->tx_stream);
101 void snd_ff_stream_destroy_duplex(struct snd_ff *ff)
103 amdtp_domain_destroy(&ff->domain);
105 destroy_stream(ff, &ff->rx_stream);
106 destroy_stream(ff, &ff->tx_stream);
109 int snd_ff_stream_reserve_duplex(struct snd_ff *ff, unsigned int rate,
117 err = ff->spec->protocol->get_clock(ff, &curr_rate, &src);
121 if (ff->substreams_counter == 0 || curr_rate != rate) {
125 amdtp_domain_stop(&ff->domain);
126 finish_session(ff);
128 fw_iso_resources_free(&ff->tx_resources);
129 fw_iso_resources_free(&ff->rx_resources);
142 err = amdtp_ff_set_parameters(&ff->tx_stream, rate,
143 ff->spec->pcm_capture_channels[mode]);
147 err = amdtp_ff_set_parameters(&ff->rx_stream, rate,
148 ff->spec->pcm_playback_channels[mode]);
152 err = ff->spec->protocol->allocate_resources(ff, rate);
156 err = amdtp_domain_set_events_per_period(&ff->domain,
159 fw_iso_resources_free(&ff->tx_resources);
160 fw_iso_resources_free(&ff->rx_resources);
168 int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
172 if (ff->substreams_counter == 0)
175 if (amdtp_streaming_error(&ff->tx_stream) ||
176 amdtp_streaming_error(&ff->rx_stream)) {
177 amdtp_domain_stop(&ff->domain);
178 finish_session(ff);
185 if (!amdtp_stream_running(&ff->rx_stream)) {
186 int spd = fw_parent_device(ff->unit)->max_speed;
188 err = ff->spec->protocol->begin_session(ff, rate);
192 err = amdtp_domain_add_stream(&ff->domain, &ff->rx_stream,
193 ff->rx_resources.channel, spd);
197 err = amdtp_domain_add_stream(&ff->domain, &ff->tx_stream,
198 ff->tx_resources.channel, spd);
202 err = amdtp_domain_start(&ff->domain, 0);
206 if (!amdtp_stream_wait_callback(&ff->rx_stream,
208 !amdtp_stream_wait_callback(&ff->tx_stream,
214 err = ff->spec->protocol->switch_fetching_mode(ff, true);
221 amdtp_domain_stop(&ff->domain);
222 finish_session(ff);
227 void snd_ff_stream_stop_duplex(struct snd_ff *ff)
229 if (ff->substreams_counter == 0) {
230 amdtp_domain_stop(&ff->domain);
231 finish_session(ff);
233 fw_iso_resources_free(&ff->tx_resources);
234 fw_iso_resources_free(&ff->rx_resources);
238 void snd_ff_stream_update_duplex(struct snd_ff *ff)
240 amdtp_domain_stop(&ff->domain);
243 amdtp_stream_pcm_abort(&ff->tx_stream);
244 amdtp_stream_pcm_abort(&ff->rx_stream);
247 void snd_ff_stream_lock_changed(struct snd_ff *ff)
249 ff->dev_lock_changed = true;
250 wake_up(&ff->hwdep_wait);
253 int snd_ff_stream_lock_try(struct snd_ff *ff)
257 spin_lock_irq(&ff->lock);
260 if (ff->dev_lock_count < 0) {
266 if (ff->dev_lock_count++ == 0)
267 snd_ff_stream_lock_changed(ff);
270 spin_unlock_irq(&ff->lock);
274 void snd_ff_stream_lock_release(struct snd_ff *ff)
276 spin_lock_irq(&ff->lock);
278 if (WARN_ON(ff->dev_lock_count <= 0))
280 if (--ff->dev_lock_count == 0)
281 snd_ff_stream_lock_changed(ff);
283 spin_unlock_irq(&ff->lock);