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
18 * to start transmitting stream. An example is 'M-Audio Firewire 410'.
59 return -EINVAL; in get_formation_index()
70 err = avc_general_get_sig_fmt(bebob->unit, &tx_rate, in snd_bebob_stream_get_rate()
72 } while (err == -EAGAIN && ++trials < 3); in snd_bebob_stream_get_rate()
78 err = avc_general_get_sig_fmt(bebob->unit, &rx_rate, in snd_bebob_stream_get_rate()
80 } while (err == -EAGAIN && ++trials < 3); in snd_bebob_stream_get_rate()
89 err = avc_general_set_sig_fmt(bebob->unit, rx_rate, in snd_bebob_stream_get_rate()
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()
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()
137 if (id >= clk_spec->num) { in snd_bebob_stream_get_clock_src()
138 dev_err(&bebob->unit->device, in snd_bebob_stream_get_clock_src()
140 id, clk_spec->num - 1); in snd_bebob_stream_get_clock_src()
141 err = -EIO; in snd_bebob_stream_get_clock_src()
145 *src = clk_spec->types[id]; 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()
208 * This source comes from iPCR[1-29]. This in snd_bebob_stream_get_clock_src()
221 err = avc_bridgeco_get_plug_type(bebob->unit, addr, in snd_bebob_stream_get_clock_src()
249 err = -EIO; in snd_bebob_stream_get_clock_src()
269 return -ENOMEM; in map_data_channels()
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()
310 err = -ENOSYS; in map_data_channels()
319 stm_pos = buf[pos++] - 1; in map_data_channels()
321 sec_loc = buf[pos++] - 1; in map_data_channels()
326 * of M-Audio don't follow this. Its location for MIDI in map_data_channels()
337 err = -ENOSYS; in map_data_channels()
357 err = -ENOSYS; in map_data_channels()
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()
392 (conn->direction == CMP_OUTPUT) ? 'o' : 'i', in check_connection_used_by_others()
393 conn->pcr_index); in check_connection_used_by_others()
394 err = -EBUSY; in check_connection_used_by_others()
402 cmp_connection_break(&bebob->in_conn); in break_both_connections()
403 cmp_connection_break(&bebob->out_conn); in break_both_connections()
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()
427 return amdtp_domain_add_stream(&bebob->domain, stream, in start_stream()
428 conn->resources.channel, conn->speed); in start_stream()
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()
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()
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()
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()
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()
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()
558 // For firmware customized by M-Audio, refer to next NOTE. 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()
598 if (bebob->substreams_counter == 0) in snd_bebob_stream_start_duplex()
599 return -EIO; 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()
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()
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()
643 // results in unrecoverable error, sometimes generate bus-reset. 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()
649 // The firmware customized by M-Audio uses these commands to 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()
664 err = -ETIMEDOUT; in snd_bebob_stream_start_duplex()
671 amdtp_domain_stop(&bebob->domain); in snd_bebob_stream_start_duplex()
678 if (bebob->substreams_counter == 0) { in snd_bebob_stream_stop_duplex()
679 amdtp_domain_stop(&bebob->domain); 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()
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()
702 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
716 return -ENOSYS; in parse_stream_formation()
724 return -ENOSYS; in parse_stream_formation()
734 /* IEC 60958 Conformant, currently handled as MBLA */ in parse_stream_formation()
744 /* IEC 61937-3 to 7 */ in parse_stream_formation()
751 case 0x07: /* DVD-Audio */ in parse_stream_formation()
763 return -ENOSYS; /* not supported */ in parse_stream_formation()
769 return -ENOSYS; in parse_stream_formation()
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()
791 return -ENXIO; in fill_stream_formations()
795 return -ENOMEM; in fill_stream_formations()
801 err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, &len, eid); in fill_stream_formations()
803 if (err == -EINVAL && eid > 0) { in fill_stream_formations()
807 dev_err(&bebob->unit->device, in fill_stream_formations()
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()
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()
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()
928 err = -ENOSYS; in snd_bebob_stream_discover()
933 bebob->rx_stream_formations); 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()
961 bebob->dev_lock_changed = true; in snd_bebob_stream_lock_changed()
962 wake_up(&bebob->hwdep_wait); in snd_bebob_stream_lock_changed()
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()
973 err = -EBUSY; in snd_bebob_stream_lock_try()
978 if (bebob->dev_lock_count++ == 0) in snd_bebob_stream_lock_try()
982 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_try()
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()
995 spin_unlock_irq(&bebob->lock); in snd_bebob_stream_lock_release()