Lines Matching +full:iec +full:- +full:60958
1 // SPDX-License-Identifier: GPL-2.0-only
3 * bebob_stream.c - a part of driver for BeBoB based devices
5 * Copyright (c) 2013-2014 Takashi Sakamoto
19 * to start transmitting stream. An example is 'M-Audio Firewire 410'.
60 return -EINVAL; in get_formation_index()
71 err = avc_general_get_sig_fmt(bebob->unit, &tx_rate, in snd_bebob_stream_get_rate()
73 } while (err == -EAGAIN && ++trials < 3); in snd_bebob_stream_get_rate()
79 err = avc_general_get_sig_fmt(bebob->unit, &rx_rate, in snd_bebob_stream_get_rate()
81 } while (err == -EAGAIN && ++trials < 3); in snd_bebob_stream_get_rate()
90 err = avc_general_set_sig_fmt(bebob->unit, rx_rate, in snd_bebob_stream_get_rate()
101 err = avc_general_set_sig_fmt(bebob->unit, rate, in snd_bebob_stream_set_rate()
106 err = avc_general_set_sig_fmt(bebob->unit, rate, in snd_bebob_stream_set_rate()
123 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; in snd_bebob_stream_get_clock_src()
131 err = clk_spec->get(bebob, &id); in snd_bebob_stream_get_clock_src()
133 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
138 if (id >= clk_spec->num) { in snd_bebob_stream_get_clock_src()
139 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
141 id, clk_spec->num - 1); in snd_bebob_stream_get_clock_src()
142 err = -EIO; in snd_bebob_stream_get_clock_src()
146 *src = clk_spec->types[id]; in snd_bebob_stream_get_clock_src()
154 if (bebob->sync_input_plug < 0) { in snd_bebob_stream_get_clock_src()
164 bebob->sync_input_plug); in snd_bebob_stream_get_clock_src()
165 err = avc_bridgeco_get_plug_input(bebob->unit, addr, input); in snd_bebob_stream_get_clock_src()
167 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
169 bebob->sync_input_plug, err); in snd_bebob_stream_get_clock_src()
209 * This source comes from iPCR[1-29]. This in snd_bebob_stream_get_clock_src()
222 err = avc_bridgeco_get_plug_type(bebob->unit, addr, in snd_bebob_stream_get_clock_src()
250 err = -EIO; in snd_bebob_stream_get_clock_src()
270 return -ENOMEM; in map_data_channels()
272 if (s == &bebob->tx_stream) in map_data_channels()
278 err = avc_bridgeco_get_plug_ch_pos(bebob->unit, addr, buf, 256); in map_data_channels()
280 dev_err(&bebob->unit->device, in map_data_channels()
299 err = avc_bridgeco_get_plug_section_type(bebob->unit, addr, in map_data_channels()
302 dev_err(&bebob->unit->device, in map_data_channels()
311 err = -ENOSYS; in map_data_channels()
320 stm_pos = buf[pos++] - 1; in map_data_channels()
322 sec_loc = buf[pos++] - 1; in map_data_channels()
327 * of M-Audio don't follow this. Its location for MIDI in map_data_channels()
338 err = -ENOSYS; in map_data_channels()
358 err = -ENOSYS; in map_data_channels()
384 if (s == &bebob->tx_stream) in check_connection_used_by_others()
385 conn = &bebob->out_conn; in check_connection_used_by_others()
387 conn = &bebob->in_conn; in check_connection_used_by_others()
391 dev_err(&bebob->unit->device, in check_connection_used_by_others()
393 (conn->direction == CMP_OUTPUT) ? 'o' : 'i', in check_connection_used_by_others()
394 conn->pcr_index); in check_connection_used_by_others()
395 err = -EBUSY; in check_connection_used_by_others()
403 cmp_connection_break(&bebob->in_conn); in break_both_connections()
404 cmp_connection_break(&bebob->out_conn); in break_both_connections()
409 if (bebob->version < 2) in break_both_connections()
418 if (stream == &bebob->rx_stream) in start_stream()
419 conn = &bebob->in_conn; in start_stream()
421 conn = &bebob->out_conn; in start_stream()
424 if (bebob->maudio_special_quirk == NULL) { in start_stream()
434 return amdtp_domain_add_stream(&bebob->domain, stream, in start_stream()
435 conn->resources.channel, conn->speed); in start_stream()
445 if (stream == &bebob->tx_stream) { in init_stream()
447 conn = &bebob->out_conn; in init_stream()
451 conn = &bebob->in_conn; in init_stream()
455 err = cmp_connection_init(conn, bebob->unit, dir_conn, 0); in init_stream()
459 err = amdtp_am824_init(stream, bebob->unit, dir_stream, CIP_BLOCKING); in init_stream()
465 if (stream == &bebob->tx_stream) { in init_stream()
467 // - In the beginning of streaming, the value of dbc is in init_stream()
469 // - The value of dbc is reset suddenly. in init_stream()
470 if (bebob->version > 2) in init_stream()
471 bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC | in init_stream()
474 // At high sampling rate, M-Audio special firmware transmits in init_stream()
476 // others are valid to IEC 61883-1. in init_stream()
477 if (bebob->maudio_special_quirk) in init_stream()
478 bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC; in init_stream()
488 if (stream == &bebob->tx_stream) in destroy_stream()
489 cmp_connection_destroy(&bebob->out_conn); in destroy_stream()
491 cmp_connection_destroy(&bebob->in_conn); in destroy_stream()
498 err = init_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
502 err = init_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_init_duplex()
504 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
508 err = amdtp_domain_init(&bebob->domain); in snd_bebob_stream_init_duplex()
510 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_init_duplex()
511 destroy_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_init_duplex()
524 if (stream == &bebob->tx_stream) { in keep_resources()
525 formation = bebob->tx_stream_formations + index; in keep_resources()
526 conn = &bebob->out_conn; in keep_resources()
528 formation = bebob->rx_stream_formations + index; in keep_resources()
529 conn = &bebob->in_conn; in keep_resources()
532 err = amdtp_am824_set_parameters(stream, rate, formation->pcm, in keep_resources()
533 formation->midi, false); in keep_resources()
549 err = check_connection_used_by_others(bebob, &bebob->rx_stream); in snd_bebob_stream_reserve_duplex()
553 err = bebob->spec->rate->get(bebob, &curr_rate); in snd_bebob_stream_reserve_duplex()
559 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_reserve_duplex()
562 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
563 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_reserve_duplex()
566 if (bebob->substreams_counter == 0 || curr_rate != rate) { in snd_bebob_stream_reserve_duplex()
573 // For firmware customized by M-Audio, refer to next NOTE. in snd_bebob_stream_reserve_duplex()
574 err = bebob->spec->rate->set(bebob, rate); in snd_bebob_stream_reserve_duplex()
576 dev_err(&bebob->unit->device, in snd_bebob_stream_reserve_duplex()
586 err = keep_resources(bebob, &bebob->tx_stream, rate, index); in snd_bebob_stream_reserve_duplex()
590 err = keep_resources(bebob, &bebob->rx_stream, rate, index); in snd_bebob_stream_reserve_duplex()
592 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
596 err = amdtp_domain_set_events_per_period(&bebob->domain, in snd_bebob_stream_reserve_duplex()
599 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_reserve_duplex()
600 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_reserve_duplex()
613 if (bebob->substreams_counter == 0) in snd_bebob_stream_start_duplex()
614 return -EIO; in snd_bebob_stream_start_duplex()
617 if (amdtp_streaming_error(&bebob->rx_stream) || in snd_bebob_stream_start_duplex()
618 amdtp_streaming_error(&bebob->tx_stream)) { in snd_bebob_stream_start_duplex()
619 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_start_duplex()
623 if (!amdtp_stream_running(&bebob->rx_stream)) { in snd_bebob_stream_start_duplex()
629 if (bebob->maudio_special_quirk) { in snd_bebob_stream_start_duplex()
630 err = bebob->spec->rate->get(bebob, &curr_rate); in snd_bebob_stream_start_duplex()
640 master = &bebob->tx_stream; in snd_bebob_stream_start_duplex()
641 slave = &bebob->rx_stream; in snd_bebob_stream_start_duplex()
643 master = &bebob->rx_stream; in snd_bebob_stream_start_duplex()
644 slave = &bebob->tx_stream; in snd_bebob_stream_start_duplex()
664 if (bebob->version < 2) in snd_bebob_stream_start_duplex()
668 err = amdtp_domain_start(&bebob->domain, ir_delay_cycle); in snd_bebob_stream_start_duplex()
673 // The firmware customized by M-Audio uses these commands to in snd_bebob_stream_start_duplex()
675 if (bebob->maudio_special_quirk) { in snd_bebob_stream_start_duplex()
676 err = bebob->spec->rate->set(bebob, curr_rate); in snd_bebob_stream_start_duplex()
678 dev_err(&bebob->unit->device, in snd_bebob_stream_start_duplex()
685 if (!amdtp_stream_wait_callback(&bebob->rx_stream, in snd_bebob_stream_start_duplex()
687 !amdtp_stream_wait_callback(&bebob->tx_stream, in snd_bebob_stream_start_duplex()
689 err = -ETIMEDOUT; in snd_bebob_stream_start_duplex()
696 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_start_duplex()
703 if (bebob->substreams_counter == 0) { in snd_bebob_stream_stop_duplex()
704 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_stop_duplex()
707 cmp_connection_release(&bebob->out_conn); in snd_bebob_stream_stop_duplex()
708 cmp_connection_release(&bebob->in_conn); in snd_bebob_stream_stop_duplex()
718 amdtp_domain_destroy(&bebob->domain); in snd_bebob_stream_destroy_duplex()
720 destroy_stream(bebob, &bebob->tx_stream); in snd_bebob_stream_destroy_duplex()
721 destroy_stream(bebob, &bebob->rx_stream); in snd_bebob_stream_destroy_duplex()
727 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
741 return -ENOSYS; in parse_stream_formation()
749 return -ENOSYS; in parse_stream_formation()
759 /* IEC 60958 Conformant, currently handled as MBLA */ in parse_stream_formation()
769 /* IEC 61937-3 to 7 */ in parse_stream_formation()
776 case 0x07: /* DVD-Audio */ in parse_stream_formation()
788 return -ENOSYS; /* not supported */ in parse_stream_formation()
794 return -ENOSYS; in parse_stream_formation()
811 return -ENOMEM; in fill_stream_formations()
814 formations = bebob->rx_stream_formations; in fill_stream_formations()
816 formations = bebob->tx_stream_formations; in fill_stream_formations()
822 err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, in fill_stream_formations()
825 if (err == -EINVAL && eid > 0) { in fill_stream_formations()
829 dev_err(&bebob->unit->device, in fill_stream_formations()
856 err = avc_general_get_plug_info(bebob->unit, 0x0c, 0x00, 0x00, plugs); in seek_msu_sync_input_plug()
858 dev_err(&bebob->unit->device, in seek_msu_sync_input_plug()
865 bebob->sync_input_plug = -1; in seek_msu_sync_input_plug()
868 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in seek_msu_sync_input_plug()
870 dev_err(&bebob->unit->device, in seek_msu_sync_input_plug()
877 bebob->sync_input_plug = i; in seek_msu_sync_input_plug()
887 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; in snd_bebob_stream_discover()
894 err = avc_general_get_plug_info(bebob->unit, 0x1f, 0x07, 0x00, plugs); in snd_bebob_stream_discover()
896 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
907 err = -ENOSYS; in snd_bebob_stream_discover()
913 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in snd_bebob_stream_discover()
915 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
919 err = -ENOSYS; in snd_bebob_stream_discover()
928 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in snd_bebob_stream_discover()
930 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
934 err = -ENOSYS; in snd_bebob_stream_discover()
942 bebob->midi_input_ports = 0; in snd_bebob_stream_discover()
946 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in snd_bebob_stream_discover()
948 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
953 bebob->midi_input_ports++; in snd_bebob_stream_discover()
958 bebob->midi_output_ports = 0; in snd_bebob_stream_discover()
962 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); in snd_bebob_stream_discover()
964 dev_err(&bebob->unit->device, in snd_bebob_stream_discover()
969 bebob->midi_output_ports++; in snd_bebob_stream_discover()
982 bebob->dev_lock_changed = true; in snd_bebob_stream_lock_changed()
983 wake_up(&bebob->hwdep_wait); in snd_bebob_stream_lock_changed()
990 spin_lock_irq(&bebob->lock); in snd_bebob_stream_lock_try()
993 if (bebob->dev_lock_count < 0) { in snd_bebob_stream_lock_try()
994 err = -EBUSY; in snd_bebob_stream_lock_try()
999 if (bebob->dev_lock_count++ == 0) in snd_bebob_stream_lock_try()
1003 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_try()
1009 spin_lock_irq(&bebob->lock); in snd_bebob_stream_lock_release()
1011 if (WARN_ON(bebob->dev_lock_count <= 0)) in snd_bebob_stream_lock_release()
1013 if (--bebob->dev_lock_count == 0) in snd_bebob_stream_lock_release()
1016 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_release()