Lines Matching +full:isoc +full:- +full:in

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'.
36 * in Additional AVC commands (Nov 2003, BridgeCo)
59 return -EINVAL;
70 err = avc_general_get_sig_fmt(bebob->unit, &tx_rate,
72 } while (err == -EAGAIN && ++trials < 3);
78 err = avc_general_get_sig_fmt(bebob->unit, &rx_rate,
80 } while (err == -EAGAIN && ++trials < 3);
89 err = avc_general_set_sig_fmt(bebob->unit, rx_rate,
100 err = avc_general_set_sig_fmt(bebob->unit, rate,
105 err = avc_general_set_sig_fmt(bebob->unit, rate,
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,
137 if (id >= clk_spec->num) {
138 dev_err(&bebob->unit->device,
140 id, clk_spec->num - 1);
141 err = -EIO;
145 *src = clk_spec->types[id];
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,
167 "fail to get an input for MSU in plug %d: %d\n",
168 bebob->sync_input_plug, err);
184 * In BeBoB architecture, the source from music subunit may
200 * SYT series of the received packets. In
208 * This source comes from iPCR[1-29]. This
221 err = avc_bridgeco_get_plug_type(bebob->unit, addr,
249 err = -EIO;
269 return -ENOMEM;
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,
280 "fail to get channel position for isoc %s plug 0: %d\n",
281 (dir == AVC_BRIDGECO_PLUG_DIR_IN) ? "in" : "out",
287 /* positions in I/O buffer */
291 /* the number of sections in AMDTP packet */
298 err = avc_bridgeco_get_plug_section_type(bebob->unit, addr,
301 dev_err(&bebob->unit->device,
302 "fail to get section type for isoc %s plug 0: %d\n",
303 (dir == AVC_BRIDGECO_PLUG_DIR_IN) ? "in" :
310 err = -ENOSYS;
314 /* the number of channels in this section */
318 /* position of this channel in AMDTP packet */
319 stm_pos = buf[pos++] - 1;
320 /* location of this channel in this section */
321 sec_loc = buf[pos++] - 1;
325 * number of channels in this section. But some models
326 * of M-Audio don't follow this. Its location for MIDI
327 * is the position of MIDI channels in AMDTP packet.
337 err = -ENOSYS;
357 err = -ENOSYS;
383 if (s == &bebob->tx_stream)
384 conn = &bebob->out_conn;
386 conn = &bebob->in_conn;
390 dev_err(&bebob->unit->device,
392 (conn->direction == CMP_OUTPUT) ? 'o' : 'i',
393 conn->pcr_index);
394 err = -EBUSY;
402 cmp_connection_break(&bebob->in_conn);
403 cmp_connection_break(&bebob->out_conn);
411 if (stream == &bebob->rx_stream)
412 conn = &bebob->in_conn;
414 conn = &bebob->out_conn;
417 if (bebob->maudio_special_quirk == NULL) {
427 return amdtp_domain_add_stream(&bebob->domain, stream,
428 conn->resources.channel, conn->speed);
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);
471 if (stream == &bebob->tx_stream)
472 cmp_connection_destroy(&bebob->out_conn);
474 cmp_connection_destroy(&bebob->in_conn);
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);
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;
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);
547 cmp_connection_release(&bebob->out_conn);
548 cmp_connection_release(&bebob->in_conn);
551 if (bebob->substreams_counter == 0 || curr_rate != rate) {
558 // For firmware customized by M-Audio, refer to next NOTE.
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);
598 if (bebob->substreams_counter == 0)
599 return -EIO;
602 if (amdtp_streaming_error(&bebob->rx_stream) ||
603 amdtp_streaming_error(&bebob->tx_stream)) {
604 amdtp_domain_stop(&bebob->domain);
608 if (!amdtp_stream_running(&bebob->rx_stream)) {
613 if (bebob->maudio_special_quirk) {
614 err = bebob->spec->rate->get(bebob, &curr_rate);
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))
637 // CMP connection. In the early stage of packet streaming, any device transfers
639 // the packet with adequate value of syt field in CIP header. Some devices are
640 // strictly to generate any discontinuity in the sequence of tx packet when they
641 // receives inadequate sequence of value in syt field of CIP header. In the case,
643 // results in unrecoverable error, sometimes generate bus-reset.
644 err = amdtp_domain_start(&bebob->domain, tx_init_skip_cycles, true, false);
649 // The firmware customized by M-Audio uses these commands to
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)) {
664 err = -ETIMEDOUT;
671 amdtp_domain_stop(&bebob->domain);
678 if (bebob->substreams_counter == 0) {
679 amdtp_domain_stop(&bebob->domain);
682 cmp_connection_release(&bebob->out_conn);
683 cmp_connection_release(&bebob->in_conn);
693 amdtp_domain_destroy(&bebob->domain);
695 destroy_stream(bebob, &bebob->tx_stream);
696 destroy_stream(bebob, &bebob->rx_stream);
701 * in Additional AVC commands (Nov 2003, BridgeCo)
702 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
716 return -ENOSYS;
724 return -ENOSYS;
744 /* IEC 61937-3 to 7 */
751 case 0x07: /* DVD-Audio */
763 return -ENOSYS; /* not supported */
769 return -ENOSYS;
785 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &plug_type);
787 dev_err(&bebob->unit->device,
788 "Fail to get type for isoc %d plug 0: %d\n", plug_dir, err);
791 return -ENXIO;
795 return -ENOMEM;
801 err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, &len, eid);
803 if (err == -EINVAL && eid > 0) {
807 dev_err(&bebob->unit->device,
808 "fail to get stream format %d for isoc %d plug %d:%d\n",
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);
860 // channels in external output plug 3 (MIDI type) even if it has a pair of physical
879 err = avc_general_get_plug_info(bebob->unit, 0x0c, 0x00, 0x00, plugs);
881 dev_err(&bebob->unit->device,
882 "fail to get info for MSU in/out plugs: %d\n",
888 bebob->sync_input_plug = -1;
891 err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type);
893 dev_err(&bebob->unit->device,
894 "fail to get type for MSU in plug %d: %d\n",
900 bebob->sync_input_plug = i;
910 const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock;
914 /* the number of plugs for isoc in/out, ext in/out */
915 err = avc_general_get_plug_info(bebob->unit, 0x1f, 0x07, 0x00, plugs);
917 dev_err(&bebob->unit->device,
918 "fail to get info for isoc/external in/out plugs: %d\n",
924 * This module supports at least one isoc input plug and one isoc
928 err = -ENOSYS;
933 bebob->rx_stream_formations);
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);
961 bebob->dev_lock_changed = true;
962 wake_up(&bebob->hwdep_wait);
967 guard(spinlock_irq)(&bebob->lock);
970 if (bebob->dev_lock_count < 0)
971 return -EBUSY;
974 if (bebob->dev_lock_count++ == 0)
981 guard(spinlock_irq)(&bebob->lock);
983 if (WARN_ON(bebob->dev_lock_count <= 0))
985 if (--bebob->dev_lock_count == 0)