Lines Matching refs:oxfw
41 static int set_rate(struct snd_oxfw *oxfw, unsigned int rate) in set_rate() argument
45 err = avc_general_set_sig_fmt(oxfw->unit, rate, in set_rate()
50 if (oxfw->has_output) in set_rate()
51 err = avc_general_set_sig_fmt(oxfw->unit, rate, in set_rate()
57 static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s, in set_stream_format() argument
66 if (s == &oxfw->tx_stream) { in set_stream_format()
67 formats = oxfw->tx_stream_formats; in set_stream_format()
70 formats = oxfw->rx_stream_formats; in set_stream_format()
87 if (oxfw->assumed) in set_stream_format()
88 return set_rate(oxfw, rate); in set_stream_format()
93 err = avc_stream_set_format(oxfw->unit, dir, 0, formats[i], len); in set_stream_format()
103 static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) in start_stream() argument
108 if (stream == &oxfw->rx_stream) in start_stream()
109 conn = &oxfw->in_conn; in start_stream()
111 conn = &oxfw->out_conn; in start_stream()
117 err = amdtp_domain_add_stream(&oxfw->domain, stream, in start_stream()
127 static int check_connection_used_by_others(struct snd_oxfw *oxfw, in check_connection_used_by_others() argument
134 if (stream == &oxfw->tx_stream) in check_connection_used_by_others()
135 conn = &oxfw->out_conn; in check_connection_used_by_others()
137 conn = &oxfw->in_conn; in check_connection_used_by_others()
141 dev_err(&oxfw->unit->device, in check_connection_used_by_others()
151 static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) in init_stream() argument
159 if (!(oxfw->quirks & SND_OXFW_QUIRK_BLOCKING_TRANSMISSION)) in init_stream()
168 if (!(oxfw->quirks & SND_OXFW_QUIRK_IGNORE_NO_INFO_PACKET)) in init_stream()
171 if (stream == &oxfw->tx_stream) { in init_stream()
172 conn = &oxfw->out_conn; in init_stream()
176 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) in init_stream()
178 if (oxfw->quirks & SND_OXFW_QUIRK_WRONG_DBS) in init_stream()
181 conn = &oxfw->in_conn; in init_stream()
186 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0); in init_stream()
190 err = amdtp_am824_init(stream, oxfw->unit, s_dir, flags); in init_stream()
199 static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream) in keep_resources() argument
208 if (stream == &oxfw->rx_stream) { in keep_resources()
210 formats = oxfw->rx_stream_formats; in keep_resources()
211 conn = &oxfw->in_conn; in keep_resources()
214 formats = oxfw->tx_stream_formats; in keep_resources()
215 conn = &oxfw->out_conn; in keep_resources()
218 err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); in keep_resources()
251 int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, in snd_oxfw_stream_reserve_duplex() argument
263 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
266 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
267 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
272 if (stream == &oxfw->tx_stream) in snd_oxfw_stream_reserve_duplex()
277 err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); in snd_oxfw_stream_reserve_duplex()
285 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_reserve_duplex()
287 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
288 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
290 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
291 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
292 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
296 if (oxfw->substreams_count == 0 || in snd_oxfw_stream_reserve_duplex()
298 err = set_stream_format(oxfw, stream, rate, pcm_channels); in snd_oxfw_stream_reserve_duplex()
300 dev_err(&oxfw->unit->device, in snd_oxfw_stream_reserve_duplex()
305 err = keep_resources(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
309 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
310 err = keep_resources(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
312 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
317 err = amdtp_domain_set_events_per_period(&oxfw->domain, in snd_oxfw_stream_reserve_duplex()
320 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
321 if (oxfw->has_output) in snd_oxfw_stream_reserve_duplex()
322 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
330 int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw) in snd_oxfw_stream_start_duplex() argument
334 if (oxfw->substreams_count == 0) in snd_oxfw_stream_start_duplex()
337 if (amdtp_streaming_error(&oxfw->rx_stream) || in snd_oxfw_stream_start_duplex()
338 amdtp_streaming_error(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
339 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
341 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
342 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
343 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
346 if (!amdtp_stream_running(&oxfw->rx_stream)) { in snd_oxfw_stream_start_duplex()
350 err = start_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_start_duplex()
352 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
357 if (oxfw->has_output && in snd_oxfw_stream_start_duplex()
358 !amdtp_stream_running(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
359 err = start_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_start_duplex()
361 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
366 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) { in snd_oxfw_stream_start_duplex()
370 } else if (oxfw->quirks & SND_OXFW_QUIRK_VOLUNTARY_RECOVERY) { in snd_oxfw_stream_start_duplex()
383 err = amdtp_domain_start(&oxfw->domain, tx_init_skip_cycles, replay_seq, false); in snd_oxfw_stream_start_duplex()
387 if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) { in snd_oxfw_stream_start_duplex()
395 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
397 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
398 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
399 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
404 void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw) in snd_oxfw_stream_stop_duplex() argument
406 if (oxfw->substreams_count == 0) { in snd_oxfw_stream_stop_duplex()
407 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_stop_duplex()
409 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
410 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
412 if (oxfw->has_output) { in snd_oxfw_stream_stop_duplex()
413 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
414 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
419 static void destroy_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) in destroy_stream() argument
423 if (stream == &oxfw->tx_stream) in destroy_stream()
424 conn = &oxfw->out_conn; in destroy_stream()
426 conn = &oxfw->in_conn; in destroy_stream()
432 int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw) in snd_oxfw_stream_init_duplex() argument
436 err = init_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
440 if (oxfw->has_output) { in snd_oxfw_stream_init_duplex()
441 err = init_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
443 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
448 err = amdtp_domain_init(&oxfw->domain); in snd_oxfw_stream_init_duplex()
450 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
451 if (oxfw->has_output) in snd_oxfw_stream_init_duplex()
452 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
460 void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw) in snd_oxfw_stream_destroy_duplex() argument
462 amdtp_domain_destroy(&oxfw->domain); in snd_oxfw_stream_destroy_duplex()
464 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_destroy_duplex()
466 if (oxfw->has_output) in snd_oxfw_stream_destroy_duplex()
467 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_destroy_duplex()
470 void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw) in snd_oxfw_stream_update_duplex() argument
472 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_update_duplex()
474 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_update_duplex()
476 amdtp_stream_pcm_abort(&oxfw->rx_stream); in snd_oxfw_stream_update_duplex()
478 if (oxfw->has_output) { in snd_oxfw_stream_update_duplex()
479 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_update_duplex()
481 amdtp_stream_pcm_abort(&oxfw->tx_stream); in snd_oxfw_stream_update_duplex()
485 int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, in snd_oxfw_stream_get_current_formation() argument
498 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len); in snd_oxfw_stream_get_current_formation()
595 assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, in assume_stream_formats() argument
604 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len); in assume_stream_formats()
606 dev_err(&oxfw->unit->device, in assume_stream_formats()
619 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
631 err = avc_general_inquiry_sig_fmt(oxfw->unit, in assume_stream_formats()
638 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
648 oxfw->assumed = true; in assume_stream_formats()
653 static int fill_stream_formats(struct snd_oxfw *oxfw, in fill_stream_formats() argument
667 formats = oxfw->tx_stream_formats; in fill_stream_formats()
669 formats = oxfw->rx_stream_formats; in fill_stream_formats()
673 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0); in fill_stream_formats()
677 err = assume_stream_formats(oxfw, dir, pid, buf, &len, in fill_stream_formats()
681 dev_err(&oxfw->unit->device, in fill_stream_formats()
701 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len, in fill_stream_formats()
710 err = avc_stream_get_format_list(oxfw->unit, dir, 0, in fill_stream_formats()
717 dev_err(&oxfw->unit->device, in fill_stream_formats()
730 int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) in snd_oxfw_stream_discover() argument
739 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs); in snd_oxfw_stream_discover()
741 dev_err(&oxfw->unit->device, in snd_oxfw_stream_discover()
752 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0); in snd_oxfw_stream_discover()
761 format = oxfw->tx_stream_formats[i]; in snd_oxfw_stream_discover()
771 oxfw->midi_input_ports = 1; in snd_oxfw_stream_discover()
774 oxfw->has_output = true; in snd_oxfw_stream_discover()
780 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0); in snd_oxfw_stream_discover()
789 format = oxfw->rx_stream_formats[i]; in snd_oxfw_stream_discover()
799 oxfw->midi_output_ports = 1; in snd_oxfw_stream_discover()
802 oxfw->has_input = true; in snd_oxfw_stream_discover()
809 void snd_oxfw_stream_lock_changed(struct snd_oxfw *oxfw) in snd_oxfw_stream_lock_changed() argument
811 oxfw->dev_lock_changed = true; in snd_oxfw_stream_lock_changed()
812 wake_up(&oxfw->hwdep_wait); in snd_oxfw_stream_lock_changed()
815 int snd_oxfw_stream_lock_try(struct snd_oxfw *oxfw) in snd_oxfw_stream_lock_try() argument
819 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
822 if (oxfw->dev_lock_count < 0) { in snd_oxfw_stream_lock_try()
828 if (oxfw->dev_lock_count++ == 0) in snd_oxfw_stream_lock_try()
829 snd_oxfw_stream_lock_changed(oxfw); in snd_oxfw_stream_lock_try()
832 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
836 void snd_oxfw_stream_lock_release(struct snd_oxfw *oxfw) in snd_oxfw_stream_lock_release() argument
838 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()
840 if (WARN_ON(oxfw->dev_lock_count <= 0)) in snd_oxfw_stream_lock_release()
842 if (--oxfw->dev_lock_count == 0) in snd_oxfw_stream_lock_release()
843 snd_oxfw_stream_lock_changed(oxfw); in snd_oxfw_stream_lock_release()
845 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()