Lines Matching refs:bebob
8 #include "./bebob.h"
64 snd_bebob_stream_get_rate(struct snd_bebob *bebob, unsigned int *curr_rate)
71 err = avc_general_get_sig_fmt(bebob->unit, &tx_rate,
79 err = avc_general_get_sig_fmt(bebob->unit, &rx_rate,
90 err = avc_general_set_sig_fmt(bebob->unit, rx_rate,
97 snd_bebob_stream_set_rate(struct snd_bebob *bebob, unsigned int rate)
101 err = avc_general_set_sig_fmt(bebob->unit, rate,
106 err = avc_general_set_sig_fmt(bebob->unit, rate,
120 int snd_bebob_stream_get_clock_src(struct snd_bebob *bebob,
123 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock;
131 err = clk_spec->get(bebob, &id);
133 dev_err(&bebob->unit->device,
139 dev_err(&bebob->unit->device,
154 if (bebob->sync_input_plug < 0) {
164 bebob->sync_input_plug);
165 err = avc_bridgeco_get_plug_input(bebob->unit, addr, input);
167 dev_err(&bebob->unit->device,
169 bebob->sync_input_plug, err);
222 err = avc_bridgeco_get_plug_type(bebob->unit, addr,
255 static int map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
272 if (s == &bebob->tx_stream)
278 err = avc_bridgeco_get_plug_ch_pos(bebob->unit, addr, buf, 256);
280 dev_err(&bebob->unit->device,
299 err = avc_bridgeco_get_plug_section_type(bebob->unit, addr,
302 dev_err(&bebob->unit->device,
378 check_connection_used_by_others(struct snd_bebob *bebob, struct amdtp_stream *s)
384 if (s == &bebob->tx_stream)
385 conn = &bebob->out_conn;
387 conn = &bebob->in_conn;
391 dev_err(&bebob->unit->device,
401 static void break_both_connections(struct snd_bebob *bebob)
403 cmp_connection_break(&bebob->in_conn);
404 cmp_connection_break(&bebob->out_conn);
409 if (bebob->version < 2)
413 static int start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream)
418 if (stream == &bebob->rx_stream)
419 conn = &bebob->in_conn;
421 conn = &bebob->out_conn;
424 if (bebob->maudio_special_quirk == NULL) {
425 err = map_data_channels(bebob, stream);
434 return amdtp_domain_add_stream(&bebob->domain, stream,
438 static int init_stream(struct snd_bebob *bebob, struct amdtp_stream *stream)
445 if (stream == &bebob->tx_stream) {
447 conn = &bebob->out_conn;
451 conn = &bebob->in_conn;
455 err = cmp_connection_init(conn, bebob->unit, dir_conn, 0);
459 err = amdtp_am824_init(stream, bebob->unit, dir_stream, CIP_BLOCKING);
465 if (stream == &bebob->tx_stream) {
470 if (bebob->version > 2)
471 bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC |
477 if (bebob->maudio_special_quirk)
478 bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC;
484 static void destroy_stream(struct snd_bebob *bebob, struct amdtp_stream *stream)
488 if (stream == &bebob->tx_stream)
489 cmp_connection_destroy(&bebob->out_conn);
491 cmp_connection_destroy(&bebob->in_conn);
494 int snd_bebob_stream_init_duplex(struct snd_bebob *bebob)
498 err = init_stream(bebob, &bebob->tx_stream);
502 err = init_stream(bebob, &bebob->rx_stream);
504 destroy_stream(bebob, &bebob->tx_stream);
508 err = amdtp_domain_init(&bebob->domain);
510 destroy_stream(bebob, &bebob->tx_stream);
511 destroy_stream(bebob, &bebob->rx_stream);
517 static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream,
525 if (stream == &bebob->tx_stream) {
526 pcm_channels = bebob->tx_stream_formations[index].pcm;
527 midi_ports = bebob->midi_input_ports;
528 conn = &bebob->out_conn;
530 pcm_channels = bebob->rx_stream_formations[index].pcm;
531 midi_ports = bebob->midi_output_ports;
532 conn = &bebob->in_conn;
542 int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate,
551 err = check_connection_used_by_others(bebob, &bebob->rx_stream);
555 err = bebob->spec->rate->get(bebob, &curr_rate);
561 amdtp_domain_stop(&bebob->domain);
562 break_both_connections(bebob);
564 cmp_connection_release(&bebob->out_conn);
565 cmp_connection_release(&bebob->in_conn);
568 if (bebob->substreams_counter == 0 || curr_rate != rate) {
576 err = bebob->spec->rate->set(bebob, rate);
578 dev_err(&bebob->unit->device,
588 err = keep_resources(bebob, &bebob->tx_stream, rate, index);
592 err = keep_resources(bebob, &bebob->rx_stream, rate, index);
594 cmp_connection_release(&bebob->out_conn);
598 err = amdtp_domain_set_events_per_period(&bebob->domain,
601 cmp_connection_release(&bebob->out_conn);
602 cmp_connection_release(&bebob->in_conn);
610 int snd_bebob_stream_start_duplex(struct snd_bebob *bebob)
615 if (bebob->substreams_counter == 0)
619 if (amdtp_streaming_error(&bebob->rx_stream) ||
620 amdtp_streaming_error(&bebob->tx_stream)) {
621 amdtp_domain_stop(&bebob->domain);
622 break_both_connections(bebob);
625 if (!amdtp_stream_running(&bebob->rx_stream)) {
631 if (bebob->maudio_special_quirk) {
632 err = bebob->spec->rate->get(bebob, &curr_rate);
637 err = snd_bebob_stream_get_clock_src(bebob, &src);
642 master = &bebob->tx_stream;
643 slave = &bebob->rx_stream;
645 master = &bebob->rx_stream;
646 slave = &bebob->tx_stream;
649 err = start_stream(bebob, master);
653 err = start_stream(bebob, slave);
666 if (bebob->version < 2)
670 err = amdtp_domain_start(&bebob->domain, ir_delay_cycle);
677 if (bebob->maudio_special_quirk) {
678 err = bebob->spec->rate->set(bebob, curr_rate);
680 dev_err(&bebob->unit->device,
687 if (!amdtp_stream_wait_callback(&bebob->rx_stream,
689 !amdtp_stream_wait_callback(&bebob->tx_stream,
698 amdtp_domain_stop(&bebob->domain);
699 break_both_connections(bebob);
703 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
705 if (bebob->substreams_counter == 0) {
706 amdtp_domain_stop(&bebob->domain);
707 break_both_connections(bebob);
709 cmp_connection_release(&bebob->out_conn);
710 cmp_connection_release(&bebob->in_conn);
718 void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob)
720 amdtp_domain_destroy(&bebob->domain);
722 destroy_stream(bebob, &bebob->tx_stream);
723 destroy_stream(bebob, &bebob->rx_stream);
802 fill_stream_formations(struct snd_bebob *bebob, enum avc_bridgeco_plug_dir dir,
816 formations = bebob->rx_stream_formations;
818 formations = bebob->tx_stream_formations;
824 err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf,
831 dev_err(&bebob->unit->device,
850 seek_msu_sync_input_plug(struct snd_bebob *bebob)
858 err = avc_general_get_plug_info(bebob->unit, 0x0c, 0x00, 0x00, plugs);
860 dev_err(&bebob->unit->device,
867 bebob->sync_input_plug = -1;
870 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
872 dev_err(&bebob->unit->device,
879 bebob->sync_input_plug = i;
887 int snd_bebob_stream_discover(struct snd_bebob *bebob)
889 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock;
896 err = avc_general_get_plug_info(bebob->unit, 0x1f, 0x07, 0x00, plugs);
898 dev_err(&bebob->unit->device,
915 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
917 dev_err(&bebob->unit->device,
924 err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_IN, 0);
930 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
932 dev_err(&bebob->unit->device,
939 err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_OUT, 0);
944 bebob->midi_input_ports = 0;
948 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
950 dev_err(&bebob->unit->device,
955 bebob->midi_input_ports++;
960 bebob->midi_output_ports = 0;
964 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
966 dev_err(&bebob->unit->device,
971 bebob->midi_output_ports++;
977 err = seek_msu_sync_input_plug(bebob);
982 void snd_bebob_stream_lock_changed(struct snd_bebob *bebob)
984 bebob->dev_lock_changed = true;
985 wake_up(&bebob->hwdep_wait);
988 int snd_bebob_stream_lock_try(struct snd_bebob *bebob)
992 spin_lock_irq(&bebob->lock);
995 if (bebob->dev_lock_count < 0) {
1001 if (bebob->dev_lock_count++ == 0)
1002 snd_bebob_stream_lock_changed(bebob);
1005 spin_unlock_irq(&bebob->lock);
1009 void snd_bebob_stream_lock_release(struct snd_bebob *bebob)
1011 spin_lock_irq(&bebob->lock);
1013 if (WARN_ON(bebob->dev_lock_count <= 0))
1015 if (--bebob->dev_lock_count == 0)
1016 snd_bebob_stream_lock_changed(bebob);
1018 spin_unlock_irq(&bebob->lock);