Lines Matching +full:isoc +full:- +full:in
1 // SPDX-License-Identifier: GPL-2.0-only
3 * oxfw_stream.c - a part of driver for OXFW970/971 based devices
29 * See Table 5.7 – Sampling frequency for Multi-bit Audio
30 * in AV/C Stream Format Information Specification 1.1 (Apr 2005, 1394TA)
45 err = avc_general_set_sig_fmt(oxfw->unit, rate,
50 if (oxfw->has_output)
51 err = avc_general_set_sig_fmt(oxfw->unit, rate,
66 if (s == &oxfw->tx_stream) {
67 formats = oxfw->tx_stream_formats;
70 formats = oxfw->rx_stream_formats;
84 return -EINVAL;
87 if (oxfw->assumed)
93 err = avc_stream_set_format(oxfw->unit, dir, 0, formats[i], len);
108 if (stream == &oxfw->rx_stream)
109 conn = &oxfw->in_conn;
111 conn = &oxfw->out_conn;
117 err = amdtp_domain_add_stream(&oxfw->domain, stream,
118 conn->resources.channel, conn->speed);
134 if (stream == &oxfw->tx_stream)
135 conn = &oxfw->out_conn;
137 conn = &oxfw->in_conn;
141 dev_err(&oxfw->unit->device,
143 (conn->direction == CMP_OUTPUT) ? 'o' : 'i',
144 conn->pcr_index);
145 err = -EBUSY;
159 if (!(oxfw->quirks & SND_OXFW_QUIRK_BLOCKING_TRANSMISSION))
165 // of value in syt field, thus the packet should include NO_INFO value in the field.
166 // However, some models just ignore data blocks in packet with NO_INFO for audio data
168 if (!(oxfw->quirks & SND_OXFW_QUIRK_IGNORE_NO_INFO_PACKET))
171 if (stream == &oxfw->tx_stream) {
172 conn = &oxfw->out_conn;
176 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD)
178 if (oxfw->quirks & SND_OXFW_QUIRK_WRONG_DBS)
180 if (oxfw->quirks & SND_OXFW_QUIRK_DBC_IS_TOTAL_PAYLOAD_QUADLETS)
183 conn = &oxfw->in_conn;
188 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0);
192 err = amdtp_am824_init(stream, oxfw->unit, s_dir, flags);
210 if (stream == &oxfw->rx_stream) {
212 formats = oxfw->rx_stream_formats;
213 conn = &oxfw->in_conn;
216 formats = oxfw->tx_stream_formats;
217 conn = &oxfw->out_conn;
239 return -EINVAL;
243 return -EINVAL;
265 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream);
268 if (oxfw->has_output) {
269 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream);
274 if (stream == &oxfw->tx_stream)
287 amdtp_domain_stop(&oxfw->domain);
289 cmp_connection_break(&oxfw->in_conn);
290 cmp_connection_release(&oxfw->in_conn);
292 if (oxfw->has_output) {
293 cmp_connection_break(&oxfw->out_conn);
294 cmp_connection_release(&oxfw->out_conn);
298 if (oxfw->substreams_count == 0 ||
302 dev_err(&oxfw->unit->device,
307 err = keep_resources(oxfw, &oxfw->rx_stream);
311 if (oxfw->has_output) {
312 err = keep_resources(oxfw, &oxfw->tx_stream);
314 cmp_connection_release(&oxfw->in_conn);
319 err = amdtp_domain_set_events_per_period(&oxfw->domain,
322 cmp_connection_release(&oxfw->in_conn);
323 if (oxfw->has_output)
324 cmp_connection_release(&oxfw->out_conn);
336 if (oxfw->substreams_count == 0)
337 return -EIO;
339 if (amdtp_streaming_error(&oxfw->rx_stream) ||
340 amdtp_streaming_error(&oxfw->tx_stream)) {
341 amdtp_domain_stop(&oxfw->domain);
343 cmp_connection_break(&oxfw->in_conn);
344 if (oxfw->has_output)
345 cmp_connection_break(&oxfw->out_conn);
348 if (!amdtp_stream_running(&oxfw->rx_stream)) {
352 err = start_stream(oxfw, &oxfw->rx_stream);
354 dev_err(&oxfw->unit->device,
359 if (oxfw->has_output &&
360 !amdtp_stream_running(&oxfw->tx_stream)) {
361 err = start_stream(oxfw, &oxfw->tx_stream);
363 dev_err(&oxfw->unit->device,
368 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) {
372 } else if (oxfw->quirks & SND_OXFW_QUIRK_VOLUNTARY_RECOVERY) {
374 // according to nominal event frequency in isochronous packets from
383 // of CIP header in received packets. The sequence of the number of data blocks per
385 err = amdtp_domain_start(&oxfw->domain, tx_init_skip_cycles, replay_seq, false);
389 if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) {
390 err = -ETIMEDOUT;
397 amdtp_domain_stop(&oxfw->domain);
399 cmp_connection_break(&oxfw->in_conn);
400 if (oxfw->has_output)
401 cmp_connection_break(&oxfw->out_conn);
408 if (oxfw->substreams_count == 0) {
409 amdtp_domain_stop(&oxfw->domain);
411 cmp_connection_break(&oxfw->in_conn);
412 cmp_connection_release(&oxfw->in_conn);
414 if (oxfw->has_output) {
415 cmp_connection_break(&oxfw->out_conn);
416 cmp_connection_release(&oxfw->out_conn);
425 if (stream == &oxfw->tx_stream)
426 conn = &oxfw->out_conn;
428 conn = &oxfw->in_conn;
438 err = init_stream(oxfw, &oxfw->rx_stream);
442 if (oxfw->has_output) {
443 err = init_stream(oxfw, &oxfw->tx_stream);
445 destroy_stream(oxfw, &oxfw->rx_stream);
450 err = amdtp_domain_init(&oxfw->domain);
452 destroy_stream(oxfw, &oxfw->rx_stream);
453 if (oxfw->has_output)
454 destroy_stream(oxfw, &oxfw->tx_stream);
464 amdtp_domain_destroy(&oxfw->domain);
466 destroy_stream(oxfw, &oxfw->rx_stream);
468 if (oxfw->has_output)
469 destroy_stream(oxfw, &oxfw->tx_stream);
474 amdtp_domain_stop(&oxfw->domain);
476 cmp_connection_break(&oxfw->in_conn);
478 amdtp_stream_pcm_abort(&oxfw->rx_stream);
480 if (oxfw->has_output) {
481 cmp_connection_break(&oxfw->out_conn);
483 amdtp_stream_pcm_abort(&oxfw->tx_stream);
493 if (!(oxfw->quirks & SND_OXFW_QUIRK_STREAM_FORMAT_INFO_UNSUPPORTED)) {
500 return -ENOMEM;
502 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len);
505 err = -EIO;
513 // command. Use the duplicated hard-coded format, instead.
518 err = avc_general_get_sig_fmt(oxfw->unit, &rate, dir, 0);
523 formats = oxfw->rx_stream_formats;
525 formats = oxfw->tx_stream_formats;
535 if (formation->rate == rate)
539 return -EIO;
546 * See Table 6.16 - AM824 Stream Format
547 * Figure 6.19 - format_information field for AM824 Compound
548 * in AV/C Stream Format Information Specification 1.1 (Apr 2005, 1394TA)
549 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
564 return -ENXIO;
572 return -ENXIO;
574 formation->rate = oxfw_rate_table[i];
585 formation->pcm += channels;
589 formation->midi = channels;
591 /* IEC 61937-3 to 7 */
598 case 0x07: /* DVD-Audio */
605 /* SMPTE Time-Code conformant */
616 return -ENXIO; /* not supported */
620 if (formation->pcm > AM824_MAX_CHANNELS_FOR_PCM ||
621 formation->midi > AM824_MAX_CHANNELS_FOR_MIDI)
622 return -ENXIO;
637 if (!(oxfw->quirks & SND_OXFW_QUIRK_STREAM_FORMAT_INFO_UNSUPPORTED)) {
638 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len);
640 dev_err(&oxfw->unit->device,
641 "fail to get current stream format for isoc %s plug %d:%d\n",
642 (dir == AVC_GENERAL_PLUG_DIR_IN) ? "in" : "out",
648 // command. Use the hard-coded format, instead.
671 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
674 err = -ENOMEM;
683 err = avc_general_inquiry_sig_fmt(oxfw->unit,
690 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
693 err = -ENOMEM;
700 oxfw->assumed = true;
716 return -ENOMEM;
719 formats = oxfw->tx_stream_formats;
721 formats = oxfw->rx_stream_formats;
725 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0);
726 if (err == -ENXIO) {
733 dev_err(&oxfw->unit->device,
734 "fail to get stream format %d for isoc %s plug %d:%d\n",
735 eid, (dir == AVC_GENERAL_PLUG_DIR_IN) ? "in" : "out",
744 err = -EIO;
753 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len,
756 err = -ENOMEM;
762 err = avc_stream_get_format_list(oxfw->unit, dir, 0,
765 if (err == -EINVAL) {
769 dev_err(&oxfw->unit->device,
770 "fail to get stream format %d for isoc %s plug %d:%d\n",
771 eid, (dir == AVC_GENERAL_PLUG_DIR_IN) ? "in" :
790 /* the number of plugs for isoc in/out, ext in/out */
791 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs);
793 dev_err(&oxfw->unit->device,
794 "fail to get info for isoc/external in/out plugs: %d\n",
798 err = -ENXIO;
806 if (err != -ENXIO)
809 // The oPCR is not available for isoc communication.
813 format = oxfw->tx_stream_formats[i];
823 oxfw->midi_input_ports = 1;
826 oxfw->has_output = true;
834 if (err != -ENXIO)
837 // The iPCR is not available for isoc communication.
841 format = oxfw->rx_stream_formats[i];
851 oxfw->midi_output_ports = 1;
854 oxfw->has_input = true;
863 oxfw->dev_lock_changed = true;
864 wake_up(&oxfw->hwdep_wait);
869 guard(spinlock_irq)(&oxfw->lock);
872 if (oxfw->dev_lock_count < 0)
873 return -EBUSY;
876 if (oxfw->dev_lock_count++ == 0)
883 guard(spinlock_irq)(&oxfw->lock);
885 if (WARN_ON(oxfw->dev_lock_count <= 0))
887 if (--oxfw->dev_lock_count == 0)