Lines Matching refs:dg00x
30 int snd_dg00x_stream_get_local_rate(struct snd_dg00x *dg00x, unsigned int *rate) in snd_dg00x_stream_get_local_rate() argument
36 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, in snd_dg00x_stream_get_local_rate()
51 int snd_dg00x_stream_set_local_rate(struct snd_dg00x *dg00x, unsigned int rate) in snd_dg00x_stream_set_local_rate() argument
64 return snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, in snd_dg00x_stream_set_local_rate()
69 int snd_dg00x_stream_get_clock(struct snd_dg00x *dg00x, in snd_dg00x_stream_get_clock() argument
75 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, in snd_dg00x_stream_get_clock()
88 int snd_dg00x_stream_check_external_clock(struct snd_dg00x *dg00x, bool *detect) in snd_dg00x_stream_check_external_clock() argument
93 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, in snd_dg00x_stream_check_external_clock()
102 int snd_dg00x_stream_get_external_rate(struct snd_dg00x *dg00x, in snd_dg00x_stream_get_external_rate() argument
109 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, in snd_dg00x_stream_get_external_rate()
125 static void finish_session(struct snd_dg00x *dg00x) in finish_session() argument
130 snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
136 snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
145 static int begin_session(struct snd_dg00x *dg00x) in begin_session() argument
152 data = cpu_to_be32((dg00x->tx_resources.channel << 16) | in begin_session()
153 dg00x->rx_resources.channel); in begin_session()
154 err = snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
160 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, in begin_session()
173 err = snd_fw_transaction(dg00x->unit, in begin_session()
188 static int keep_resources(struct snd_dg00x *dg00x, struct amdtp_stream *stream, in keep_resources() argument
203 if (stream == &dg00x->tx_stream) in keep_resources()
204 resources = &dg00x->tx_resources; in keep_resources()
206 resources = &dg00x->rx_resources; in keep_resources()
215 fw_parent_device(dg00x->unit)->max_speed); in keep_resources()
218 static int init_stream(struct snd_dg00x *dg00x, struct amdtp_stream *s) in init_stream() argument
224 if (s == &dg00x->tx_stream) { in init_stream()
225 resources = &dg00x->tx_resources; in init_stream()
228 resources = &dg00x->rx_resources; in init_stream()
232 err = fw_iso_resources_init(resources, dg00x->unit); in init_stream()
236 err = amdtp_dot_init(s, dg00x->unit, dir); in init_stream()
243 static void destroy_stream(struct snd_dg00x *dg00x, struct amdtp_stream *s) in destroy_stream() argument
247 if (s == &dg00x->tx_stream) in destroy_stream()
248 fw_iso_resources_destroy(&dg00x->tx_resources); in destroy_stream()
250 fw_iso_resources_destroy(&dg00x->rx_resources); in destroy_stream()
253 int snd_dg00x_stream_init_duplex(struct snd_dg00x *dg00x) in snd_dg00x_stream_init_duplex() argument
257 err = init_stream(dg00x, &dg00x->rx_stream); in snd_dg00x_stream_init_duplex()
261 err = init_stream(dg00x, &dg00x->tx_stream); in snd_dg00x_stream_init_duplex()
263 destroy_stream(dg00x, &dg00x->rx_stream); in snd_dg00x_stream_init_duplex()
265 err = amdtp_domain_init(&dg00x->domain); in snd_dg00x_stream_init_duplex()
267 destroy_stream(dg00x, &dg00x->rx_stream); in snd_dg00x_stream_init_duplex()
268 destroy_stream(dg00x, &dg00x->tx_stream); in snd_dg00x_stream_init_duplex()
278 void snd_dg00x_stream_destroy_duplex(struct snd_dg00x *dg00x) in snd_dg00x_stream_destroy_duplex() argument
280 amdtp_domain_destroy(&dg00x->domain); in snd_dg00x_stream_destroy_duplex()
282 destroy_stream(dg00x, &dg00x->rx_stream); in snd_dg00x_stream_destroy_duplex()
283 destroy_stream(dg00x, &dg00x->tx_stream); in snd_dg00x_stream_destroy_duplex()
286 int snd_dg00x_stream_reserve_duplex(struct snd_dg00x *dg00x, unsigned int rate, in snd_dg00x_stream_reserve_duplex() argument
293 err = snd_dg00x_stream_get_local_rate(dg00x, &curr_rate); in snd_dg00x_stream_reserve_duplex()
299 if (dg00x->substreams_counter == 0 || curr_rate != rate) { in snd_dg00x_stream_reserve_duplex()
300 amdtp_domain_stop(&dg00x->domain); in snd_dg00x_stream_reserve_duplex()
302 finish_session(dg00x); in snd_dg00x_stream_reserve_duplex()
304 fw_iso_resources_free(&dg00x->tx_resources); in snd_dg00x_stream_reserve_duplex()
305 fw_iso_resources_free(&dg00x->rx_resources); in snd_dg00x_stream_reserve_duplex()
307 err = snd_dg00x_stream_set_local_rate(dg00x, rate); in snd_dg00x_stream_reserve_duplex()
311 err = keep_resources(dg00x, &dg00x->rx_stream, rate); in snd_dg00x_stream_reserve_duplex()
315 err = keep_resources(dg00x, &dg00x->tx_stream, rate); in snd_dg00x_stream_reserve_duplex()
317 fw_iso_resources_free(&dg00x->rx_resources); in snd_dg00x_stream_reserve_duplex()
321 err = amdtp_domain_set_events_per_period(&dg00x->domain, in snd_dg00x_stream_reserve_duplex()
324 fw_iso_resources_free(&dg00x->rx_resources); in snd_dg00x_stream_reserve_duplex()
325 fw_iso_resources_free(&dg00x->tx_resources); in snd_dg00x_stream_reserve_duplex()
333 int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x) in snd_dg00x_stream_start_duplex() argument
335 unsigned int generation = dg00x->rx_resources.generation; in snd_dg00x_stream_start_duplex()
338 if (dg00x->substreams_counter == 0) in snd_dg00x_stream_start_duplex()
341 if (amdtp_streaming_error(&dg00x->tx_stream) || in snd_dg00x_stream_start_duplex()
342 amdtp_streaming_error(&dg00x->rx_stream)) { in snd_dg00x_stream_start_duplex()
343 amdtp_domain_stop(&dg00x->domain); in snd_dg00x_stream_start_duplex()
344 finish_session(dg00x); in snd_dg00x_stream_start_duplex()
347 if (generation != fw_parent_device(dg00x->unit)->card->generation) { in snd_dg00x_stream_start_duplex()
348 err = fw_iso_resources_update(&dg00x->tx_resources); in snd_dg00x_stream_start_duplex()
352 err = fw_iso_resources_update(&dg00x->rx_resources); in snd_dg00x_stream_start_duplex()
361 if (!amdtp_stream_running(&dg00x->rx_stream)) { in snd_dg00x_stream_start_duplex()
362 int spd = fw_parent_device(dg00x->unit)->max_speed; in snd_dg00x_stream_start_duplex()
364 err = begin_session(dg00x); in snd_dg00x_stream_start_duplex()
368 err = amdtp_domain_add_stream(&dg00x->domain, &dg00x->rx_stream, in snd_dg00x_stream_start_duplex()
369 dg00x->rx_resources.channel, spd); in snd_dg00x_stream_start_duplex()
373 err = amdtp_domain_add_stream(&dg00x->domain, &dg00x->tx_stream, in snd_dg00x_stream_start_duplex()
374 dg00x->tx_resources.channel, spd); in snd_dg00x_stream_start_duplex()
382 err = amdtp_domain_start(&dg00x->domain, 0, true, true); in snd_dg00x_stream_start_duplex()
386 if (!amdtp_domain_wait_ready(&dg00x->domain, READY_TIMEOUT_MS)) { in snd_dg00x_stream_start_duplex()
394 amdtp_domain_stop(&dg00x->domain); in snd_dg00x_stream_start_duplex()
395 finish_session(dg00x); in snd_dg00x_stream_start_duplex()
400 void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x) in snd_dg00x_stream_stop_duplex() argument
402 if (dg00x->substreams_counter == 0) { in snd_dg00x_stream_stop_duplex()
403 amdtp_domain_stop(&dg00x->domain); in snd_dg00x_stream_stop_duplex()
404 finish_session(dg00x); in snd_dg00x_stream_stop_duplex()
406 fw_iso_resources_free(&dg00x->tx_resources); in snd_dg00x_stream_stop_duplex()
407 fw_iso_resources_free(&dg00x->rx_resources); in snd_dg00x_stream_stop_duplex()
411 void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x) in snd_dg00x_stream_update_duplex() argument
413 fw_iso_resources_update(&dg00x->tx_resources); in snd_dg00x_stream_update_duplex()
414 fw_iso_resources_update(&dg00x->rx_resources); in snd_dg00x_stream_update_duplex()
416 amdtp_stream_update(&dg00x->tx_stream); in snd_dg00x_stream_update_duplex()
417 amdtp_stream_update(&dg00x->rx_stream); in snd_dg00x_stream_update_duplex()
420 void snd_dg00x_stream_lock_changed(struct snd_dg00x *dg00x) in snd_dg00x_stream_lock_changed() argument
422 dg00x->dev_lock_changed = true; in snd_dg00x_stream_lock_changed()
423 wake_up(&dg00x->hwdep_wait); in snd_dg00x_stream_lock_changed()
426 int snd_dg00x_stream_lock_try(struct snd_dg00x *dg00x) in snd_dg00x_stream_lock_try() argument
430 spin_lock_irq(&dg00x->lock); in snd_dg00x_stream_lock_try()
433 if (dg00x->dev_lock_count < 0) { in snd_dg00x_stream_lock_try()
439 if (dg00x->dev_lock_count++ == 0) in snd_dg00x_stream_lock_try()
440 snd_dg00x_stream_lock_changed(dg00x); in snd_dg00x_stream_lock_try()
443 spin_unlock_irq(&dg00x->lock); in snd_dg00x_stream_lock_try()
447 void snd_dg00x_stream_lock_release(struct snd_dg00x *dg00x) in snd_dg00x_stream_lock_release() argument
449 spin_lock_irq(&dg00x->lock); in snd_dg00x_stream_lock_release()
451 if (WARN_ON(dg00x->dev_lock_count <= 0)) in snd_dg00x_stream_lock_release()
453 if (--dg00x->dev_lock_count == 0) in snd_dg00x_stream_lock_release()
454 snd_dg00x_stream_lock_changed(dg00x); in snd_dg00x_stream_lock_release()
456 spin_unlock_irq(&dg00x->lock); in snd_dg00x_stream_lock_release()