Lines Matching refs:bebob

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