Lines Matching refs:bebob

63 snd_bebob_stream_get_rate(struct snd_bebob *bebob, unsigned int *curr_rate)  in snd_bebob_stream_get_rate()  argument
70 err = avc_general_get_sig_fmt(bebob->unit, &tx_rate, in snd_bebob_stream_get_rate()
78 err = avc_general_get_sig_fmt(bebob->unit, &rx_rate, in snd_bebob_stream_get_rate()
89 err = avc_general_set_sig_fmt(bebob->unit, rx_rate, in snd_bebob_stream_get_rate()
96 snd_bebob_stream_set_rate(struct snd_bebob *bebob, unsigned int rate) in snd_bebob_stream_set_rate() argument
100 err = avc_general_set_sig_fmt(bebob->unit, rate, in snd_bebob_stream_set_rate()
105 err = avc_general_set_sig_fmt(bebob->unit, rate, in snd_bebob_stream_set_rate()
119 int snd_bebob_stream_get_clock_src(struct snd_bebob *bebob, in snd_bebob_stream_get_clock_src() argument
122 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; in snd_bebob_stream_get_clock_src()
130 err = clk_spec->get(bebob, &id); in snd_bebob_stream_get_clock_src()
132 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
138 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
153 if (bebob->sync_input_plug < 0) { in snd_bebob_stream_get_clock_src()
163 bebob->sync_input_plug); in snd_bebob_stream_get_clock_src()
164 err = avc_bridgeco_get_plug_input(bebob->unit, addr, input); in snd_bebob_stream_get_clock_src()
166 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
168 bebob->sync_input_plug, err); in snd_bebob_stream_get_clock_src()
221 err = avc_bridgeco_get_plug_type(bebob->unit, addr, in snd_bebob_stream_get_clock_src()
254 static int map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s) in map_data_channels() argument
271 if (s == &bebob->tx_stream) in map_data_channels()
277 err = avc_bridgeco_get_plug_ch_pos(bebob->unit, addr, buf, 256); in map_data_channels()
279 dev_err(&bebob->unit->device, in map_data_channels()
298 err = avc_bridgeco_get_plug_section_type(bebob->unit, addr, in map_data_channels()
301 dev_err(&bebob->unit->device, in map_data_channels()
377 check_connection_used_by_others(struct snd_bebob *bebob, struct amdtp_stream *s) in check_connection_used_by_others() argument
383 if (s == &bebob->tx_stream) in check_connection_used_by_others()
384 conn = &bebob->out_conn; in check_connection_used_by_others()
386 conn = &bebob->in_conn; in check_connection_used_by_others()
390 dev_err(&bebob->unit->device, in check_connection_used_by_others()
400 static void break_both_connections(struct snd_bebob *bebob) in break_both_connections() argument
402 cmp_connection_break(&bebob->in_conn); in break_both_connections()
403 cmp_connection_break(&bebob->out_conn); in break_both_connections()
406 static int start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) in start_stream() argument
411 if (stream == &bebob->rx_stream) in start_stream()
412 conn = &bebob->in_conn; in start_stream()
414 conn = &bebob->out_conn; in start_stream()
417 if (bebob->maudio_special_quirk == NULL) { in start_stream()
418 err = map_data_channels(bebob, stream); in start_stream()
427 return amdtp_domain_add_stream(&bebob->domain, stream, in start_stream()
431 static int init_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) in init_stream() argument
439 if (stream == &bebob->tx_stream) { in init_stream()
441 conn = &bebob->out_conn; in init_stream()
445 conn = &bebob->in_conn; in init_stream()
449 if (stream == &bebob->tx_stream) { in init_stream()
450 if (bebob->quirks & SND_BEBOB_QUIRK_WRONG_DBC) in init_stream()
454 err = cmp_connection_init(conn, bebob->unit, dir_conn, 0); in init_stream()
458 err = amdtp_am824_init(stream, bebob->unit, dir_stream, flags); in init_stream()
467 static void destroy_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) in destroy_stream() argument
471 if (stream == &bebob->tx_stream) in destroy_stream()
472 cmp_connection_destroy(&bebob->out_conn); in destroy_stream()
474 cmp_connection_destroy(&bebob->in_conn); in destroy_stream()
477 int snd_bebob_stream_init_duplex(struct snd_bebob *bebob) in snd_bebob_stream_init_duplex() argument
481 err = init_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
485 err = init_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_init_duplex()
487 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
491 err = amdtp_domain_init(&bebob->domain); in snd_bebob_stream_init_duplex()
493 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
494 destroy_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_init_duplex()
500 static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream, in keep_resources() argument
508 if (stream == &bebob->tx_stream) { in keep_resources()
509 pcm_channels = bebob->tx_stream_formations[index].pcm; in keep_resources()
510 midi_ports = bebob->midi_input_ports; in keep_resources()
511 conn = &bebob->out_conn; in keep_resources()
513 pcm_channels = bebob->rx_stream_formations[index].pcm; in keep_resources()
514 midi_ports = bebob->midi_output_ports; in keep_resources()
515 conn = &bebob->in_conn; in keep_resources()
525 int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate, in snd_bebob_stream_reserve_duplex() argument
534 err = check_connection_used_by_others(bebob, &bebob->rx_stream); in snd_bebob_stream_reserve_duplex()
538 err = bebob->spec->rate->get(bebob, &curr_rate); in snd_bebob_stream_reserve_duplex()
544 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_reserve_duplex()
545 break_both_connections(bebob); in snd_bebob_stream_reserve_duplex()
547 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
548 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_reserve_duplex()
551 if (bebob->substreams_counter == 0 || curr_rate != rate) { in snd_bebob_stream_reserve_duplex()
559 err = bebob->spec->rate->set(bebob, rate); in snd_bebob_stream_reserve_duplex()
561 dev_err(&bebob->unit->device, in snd_bebob_stream_reserve_duplex()
571 err = keep_resources(bebob, &bebob->tx_stream, rate, index); in snd_bebob_stream_reserve_duplex()
575 err = keep_resources(bebob, &bebob->rx_stream, rate, index); in snd_bebob_stream_reserve_duplex()
577 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
581 err = amdtp_domain_set_events_per_period(&bebob->domain, in snd_bebob_stream_reserve_duplex()
584 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
585 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_reserve_duplex()
593 int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) in snd_bebob_stream_start_duplex() argument
598 if (bebob->substreams_counter == 0) in snd_bebob_stream_start_duplex()
602 if (amdtp_streaming_error(&bebob->rx_stream) || in snd_bebob_stream_start_duplex()
603 amdtp_streaming_error(&bebob->tx_stream)) { in snd_bebob_stream_start_duplex()
604 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_start_duplex()
605 break_both_connections(bebob); in snd_bebob_stream_start_duplex()
608 if (!amdtp_stream_running(&bebob->rx_stream)) { in snd_bebob_stream_start_duplex()
613 if (bebob->maudio_special_quirk) { in snd_bebob_stream_start_duplex()
614 err = bebob->spec->rate->get(bebob, &curr_rate); in snd_bebob_stream_start_duplex()
619 err = snd_bebob_stream_get_clock_src(bebob, &src); in snd_bebob_stream_start_duplex()
623 err = start_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_start_duplex()
627 err = start_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_start_duplex()
631 if (!(bebob->quirks & SND_BEBOB_QUIRK_INITIAL_DISCONTINUOUS_DBC)) in snd_bebob_stream_start_duplex()
644 err = amdtp_domain_start(&bebob->domain, tx_init_skip_cycles, true, false); in snd_bebob_stream_start_duplex()
651 if (bebob->maudio_special_quirk) { in snd_bebob_stream_start_duplex()
652 err = bebob->spec->rate->set(bebob, curr_rate); in snd_bebob_stream_start_duplex()
654 dev_err(&bebob->unit->device, in snd_bebob_stream_start_duplex()
663 if (!amdtp_domain_wait_ready(&bebob->domain, READY_TIMEOUT_MS)) { in snd_bebob_stream_start_duplex()
671 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_start_duplex()
672 break_both_connections(bebob); in snd_bebob_stream_start_duplex()
676 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob) in snd_bebob_stream_stop_duplex() argument
678 if (bebob->substreams_counter == 0) { in snd_bebob_stream_stop_duplex()
679 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_stop_duplex()
680 break_both_connections(bebob); in snd_bebob_stream_stop_duplex()
682 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_stop_duplex()
683 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_stop_duplex()
691 void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob) in snd_bebob_stream_destroy_duplex() argument
693 amdtp_domain_destroy(&bebob->domain); in snd_bebob_stream_destroy_duplex()
695 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_destroy_duplex()
696 destroy_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_destroy_duplex()
774 static int fill_stream_formations(struct snd_bebob *bebob, u8 addr[AVC_BRIDGECO_ADDR_BYTES], in fill_stream_formations() argument
785 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &plug_type); in fill_stream_formations()
787 dev_err(&bebob->unit->device, in fill_stream_formations()
801 err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, &len, eid); in fill_stream_formations()
807 dev_err(&bebob->unit->device, in fill_stream_formations()
822 static int detect_midi_ports(struct snd_bebob *bebob, in detect_midi_ports() argument
846 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &plug_type); in detect_midi_ports()
848 dev_err(&bebob->unit->device, in detect_midi_ports()
856 err = avc_bridgeco_get_plug_ch_count(bebob->unit, addr, &ch_count); in detect_midi_ports()
871 seek_msu_sync_input_plug(struct snd_bebob *bebob) in seek_msu_sync_input_plug() argument
879 err = avc_general_get_plug_info(bebob->unit, 0x0c, 0x00, 0x00, plugs); in seek_msu_sync_input_plug()
881 dev_err(&bebob->unit->device, in seek_msu_sync_input_plug()
888 bebob->sync_input_plug = -1; in seek_msu_sync_input_plug()
891 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in seek_msu_sync_input_plug()
893 dev_err(&bebob->unit->device, in seek_msu_sync_input_plug()
900 bebob->sync_input_plug = i; in seek_msu_sync_input_plug()
908 int snd_bebob_stream_discover(struct snd_bebob *bebob) in snd_bebob_stream_discover() argument
910 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; in snd_bebob_stream_discover()
915 err = avc_general_get_plug_info(bebob->unit, 0x1f, 0x07, 0x00, plugs); in snd_bebob_stream_discover()
917 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
932 err = fill_stream_formations(bebob, addr, AVC_BRIDGECO_PLUG_DIR_IN, 0, in snd_bebob_stream_discover()
933 bebob->rx_stream_formations); in snd_bebob_stream_discover()
937 err = fill_stream_formations(bebob, addr, AVC_BRIDGECO_PLUG_DIR_OUT, 0, in snd_bebob_stream_discover()
938 bebob->tx_stream_formations); in snd_bebob_stream_discover()
942 err = detect_midi_ports(bebob, bebob->tx_stream_formations, addr, AVC_BRIDGECO_PLUG_DIR_IN, in snd_bebob_stream_discover()
943 plugs[2], &bebob->midi_input_ports); in snd_bebob_stream_discover()
947 err = detect_midi_ports(bebob, bebob->rx_stream_formations, addr, AVC_BRIDGECO_PLUG_DIR_OUT, in snd_bebob_stream_discover()
948 plugs[3], &bebob->midi_output_ports); in snd_bebob_stream_discover()
954 err = seek_msu_sync_input_plug(bebob); in snd_bebob_stream_discover()
959 void snd_bebob_stream_lock_changed(struct snd_bebob *bebob) in snd_bebob_stream_lock_changed() argument
961 bebob->dev_lock_changed = true; in snd_bebob_stream_lock_changed()
962 wake_up(&bebob->hwdep_wait); in snd_bebob_stream_lock_changed()
965 int snd_bebob_stream_lock_try(struct snd_bebob *bebob) in snd_bebob_stream_lock_try() argument
969 spin_lock_irq(&bebob->lock); in snd_bebob_stream_lock_try()
972 if (bebob->dev_lock_count < 0) { in snd_bebob_stream_lock_try()
978 if (bebob->dev_lock_count++ == 0) in snd_bebob_stream_lock_try()
979 snd_bebob_stream_lock_changed(bebob); in snd_bebob_stream_lock_try()
982 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_try()
986 void snd_bebob_stream_lock_release(struct snd_bebob *bebob) in snd_bebob_stream_lock_release() argument
988 spin_lock_irq(&bebob->lock); in snd_bebob_stream_lock_release()
990 if (WARN_ON(bebob->dev_lock_count <= 0)) in snd_bebob_stream_lock_release()
992 if (--bebob->dev_lock_count == 0) in snd_bebob_stream_lock_release()
993 snd_bebob_stream_lock_changed(bebob); in snd_bebob_stream_lock_release()
995 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_release()