Lines Matching +full:iec +full:- +full:60958

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
45 err = avc_general_set_sig_fmt(oxfw->unit, rate, in set_rate()
50 if (oxfw->has_output) in set_rate()
51 err = avc_general_set_sig_fmt(oxfw->unit, rate, in set_rate()
66 if (s == &oxfw->tx_stream) { in set_stream_format()
67 formats = oxfw->tx_stream_formats; in set_stream_format()
70 formats = oxfw->rx_stream_formats; in set_stream_format()
84 return -EINVAL; in set_stream_format()
87 if (oxfw->assumed) in set_stream_format()
93 err = avc_stream_set_format(oxfw->unit, dir, 0, formats[i], len); in set_stream_format()
108 if (stream == &oxfw->rx_stream) in start_stream()
109 conn = &oxfw->in_conn; in start_stream()
111 conn = &oxfw->out_conn; in start_stream()
117 err = amdtp_domain_add_stream(&oxfw->domain, stream, in start_stream()
118 conn->resources.channel, conn->speed); in start_stream()
134 if (stream == &oxfw->tx_stream) in check_connection_used_by_others()
135 conn = &oxfw->out_conn; in check_connection_used_by_others()
137 conn = &oxfw->in_conn; in check_connection_used_by_others()
141 dev_err(&oxfw->unit->device, in check_connection_used_by_others()
143 (conn->direction == CMP_OUTPUT) ? 'o' : 'i', in check_connection_used_by_others()
144 conn->pcr_index); in check_connection_used_by_others()
145 err = -EBUSY; in check_connection_used_by_others()
159 if (!(oxfw->quirks & SND_OXFW_QUIRK_BLOCKING_TRANSMISSION)) in init_stream()
168 if (!(oxfw->quirks & SND_OXFW_QUIRK_IGNORE_NO_INFO_PACKET)) in init_stream()
171 if (stream == &oxfw->tx_stream) { in init_stream()
172 conn = &oxfw->out_conn; in init_stream()
176 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) in init_stream()
178 if (oxfw->quirks & SND_OXFW_QUIRK_WRONG_DBS) in init_stream()
180 if (oxfw->quirks & SND_OXFW_QUIRK_DBC_IS_TOTAL_PAYLOAD_QUADLETS) in init_stream()
183 conn = &oxfw->in_conn; in init_stream()
188 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0); in init_stream()
192 err = amdtp_am824_init(stream, oxfw->unit, s_dir, flags); in init_stream()
210 if (stream == &oxfw->rx_stream) { in keep_resources()
212 formats = oxfw->rx_stream_formats; in keep_resources()
213 conn = &oxfw->in_conn; in keep_resources()
216 formats = oxfw->tx_stream_formats; in keep_resources()
217 conn = &oxfw->out_conn; in keep_resources()
239 return -EINVAL; in keep_resources()
243 return -EINVAL; in keep_resources()
265 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
268 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
269 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
274 if (stream == &oxfw->tx_stream) in snd_oxfw_stream_reserve_duplex()
287 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_reserve_duplex()
289 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
290 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
292 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
293 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
294 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
298 if (oxfw->substreams_count == 0 || in snd_oxfw_stream_reserve_duplex()
302 dev_err(&oxfw->unit->device, in snd_oxfw_stream_reserve_duplex()
307 err = keep_resources(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
311 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
312 err = keep_resources(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
314 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
319 err = amdtp_domain_set_events_per_period(&oxfw->domain, in snd_oxfw_stream_reserve_duplex()
322 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
323 if (oxfw->has_output) in snd_oxfw_stream_reserve_duplex()
324 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
336 if (oxfw->substreams_count == 0) in snd_oxfw_stream_start_duplex()
337 return -EIO; in snd_oxfw_stream_start_duplex()
339 if (amdtp_streaming_error(&oxfw->rx_stream) || in snd_oxfw_stream_start_duplex()
340 amdtp_streaming_error(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
341 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
343 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
344 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
345 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
348 if (!amdtp_stream_running(&oxfw->rx_stream)) { in snd_oxfw_stream_start_duplex()
352 err = start_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_start_duplex()
354 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
359 if (oxfw->has_output && in snd_oxfw_stream_start_duplex()
360 !amdtp_stream_running(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
361 err = start_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_start_duplex()
363 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
368 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) { in snd_oxfw_stream_start_duplex()
372 } else if (oxfw->quirks & SND_OXFW_QUIRK_VOLUNTARY_RECOVERY) { in snd_oxfw_stream_start_duplex()
385 err = amdtp_domain_start(&oxfw->domain, tx_init_skip_cycles, replay_seq, false); in snd_oxfw_stream_start_duplex()
389 if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) { in snd_oxfw_stream_start_duplex()
390 err = -ETIMEDOUT; in snd_oxfw_stream_start_duplex()
397 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
399 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
400 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
401 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
408 if (oxfw->substreams_count == 0) { in snd_oxfw_stream_stop_duplex()
409 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_stop_duplex()
411 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
412 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
414 if (oxfw->has_output) { in snd_oxfw_stream_stop_duplex()
415 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
416 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
425 if (stream == &oxfw->tx_stream) in destroy_stream()
426 conn = &oxfw->out_conn; in destroy_stream()
428 conn = &oxfw->in_conn; in destroy_stream()
438 err = init_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
442 if (oxfw->has_output) { in snd_oxfw_stream_init_duplex()
443 err = init_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
445 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
450 err = amdtp_domain_init(&oxfw->domain); in snd_oxfw_stream_init_duplex()
452 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
453 if (oxfw->has_output) in snd_oxfw_stream_init_duplex()
454 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
464 amdtp_domain_destroy(&oxfw->domain); in snd_oxfw_stream_destroy_duplex()
466 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_destroy_duplex()
468 if (oxfw->has_output) in snd_oxfw_stream_destroy_duplex()
469 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_destroy_duplex()
474 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_update_duplex()
476 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_update_duplex()
478 amdtp_stream_pcm_abort(&oxfw->rx_stream); in snd_oxfw_stream_update_duplex()
480 if (oxfw->has_output) { in snd_oxfw_stream_update_duplex()
481 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_update_duplex()
483 amdtp_stream_pcm_abort(&oxfw->tx_stream); in snd_oxfw_stream_update_duplex()
493 if (!(oxfw->quirks & SND_OXFW_QUIRK_STREAM_FORMAT_INFO_UNSUPPORTED)) { in snd_oxfw_stream_get_current_formation()
500 return -ENOMEM; in snd_oxfw_stream_get_current_formation()
502 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len); in snd_oxfw_stream_get_current_formation()
505 err = -EIO; in snd_oxfw_stream_get_current_formation()
513 // command. Use the duplicated hard-coded format, instead. in snd_oxfw_stream_get_current_formation()
518 err = avc_general_get_sig_fmt(oxfw->unit, &rate, dir, 0); in snd_oxfw_stream_get_current_formation()
523 formats = oxfw->rx_stream_formats; in snd_oxfw_stream_get_current_formation()
525 formats = oxfw->tx_stream_formats; in snd_oxfw_stream_get_current_formation()
535 if (formation->rate == rate) in snd_oxfw_stream_get_current_formation()
539 return -EIO; in snd_oxfw_stream_get_current_formation()
546 * See Table 6.16 - AM824 Stream Format
547 * Figure 6.19 - format_information field for AM824 Compound
549 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
564 return -ENXIO; in snd_oxfw_stream_parse_format()
572 return -ENXIO; in snd_oxfw_stream_parse_format()
574 formation->rate = oxfw_rate_table[i]; in snd_oxfw_stream_parse_format()
581 /* IEC 60958 Conformant, currently handled as MBLA */ in snd_oxfw_stream_parse_format()
585 formation->pcm += channels; in snd_oxfw_stream_parse_format()
589 formation->midi = channels; in snd_oxfw_stream_parse_format()
591 /* IEC 61937-3 to 7 */ in snd_oxfw_stream_parse_format()
598 case 0x07: /* DVD-Audio */ in snd_oxfw_stream_parse_format()
605 /* SMPTE Time-Code conformant */ in snd_oxfw_stream_parse_format()
616 return -ENXIO; /* not supported */ in snd_oxfw_stream_parse_format()
620 if (formation->pcm > AM824_MAX_CHANNELS_FOR_PCM || in snd_oxfw_stream_parse_format()
621 formation->midi > AM824_MAX_CHANNELS_FOR_MIDI) in snd_oxfw_stream_parse_format()
622 return -ENXIO; in snd_oxfw_stream_parse_format()
637 if (!(oxfw->quirks & SND_OXFW_QUIRK_STREAM_FORMAT_INFO_UNSUPPORTED)) { in assume_stream_formats()
638 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len); in assume_stream_formats()
640 dev_err(&oxfw->unit->device, in assume_stream_formats()
648 // command. Use the hard-coded format, instead. in assume_stream_formats()
671 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
674 err = -ENOMEM; in assume_stream_formats()
683 err = avc_general_inquiry_sig_fmt(oxfw->unit, in assume_stream_formats()
690 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
693 err = -ENOMEM; in assume_stream_formats()
700 oxfw->assumed = true; in assume_stream_formats()
716 return -ENOMEM; in fill_stream_formats()
719 formats = oxfw->tx_stream_formats; in fill_stream_formats()
721 formats = oxfw->rx_stream_formats; in fill_stream_formats()
725 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0); in fill_stream_formats()
726 if (err == -ENXIO) { in fill_stream_formats()
733 dev_err(&oxfw->unit->device, in fill_stream_formats()
744 err = -EIO; in fill_stream_formats()
753 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len, in fill_stream_formats()
756 err = -ENOMEM; in fill_stream_formats()
762 err = avc_stream_get_format_list(oxfw->unit, dir, 0, in fill_stream_formats()
765 if (err == -EINVAL) { in fill_stream_formats()
769 dev_err(&oxfw->unit->device, in fill_stream_formats()
791 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs); in snd_oxfw_stream_discover()
793 dev_err(&oxfw->unit->device, in snd_oxfw_stream_discover()
798 err = -ENXIO; in snd_oxfw_stream_discover()
806 if (err != -ENXIO) in snd_oxfw_stream_discover()
813 format = oxfw->tx_stream_formats[i]; in snd_oxfw_stream_discover()
823 oxfw->midi_input_ports = 1; in snd_oxfw_stream_discover()
826 oxfw->has_output = true; in snd_oxfw_stream_discover()
834 if (err != -ENXIO) in snd_oxfw_stream_discover()
841 format = oxfw->rx_stream_formats[i]; in snd_oxfw_stream_discover()
851 oxfw->midi_output_ports = 1; in snd_oxfw_stream_discover()
854 oxfw->has_input = true; in snd_oxfw_stream_discover()
863 oxfw->dev_lock_changed = true; in snd_oxfw_stream_lock_changed()
864 wake_up(&oxfw->hwdep_wait); in snd_oxfw_stream_lock_changed()
871 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
874 if (oxfw->dev_lock_count < 0) { in snd_oxfw_stream_lock_try()
875 err = -EBUSY; in snd_oxfw_stream_lock_try()
880 if (oxfw->dev_lock_count++ == 0) in snd_oxfw_stream_lock_try()
884 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
890 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()
892 if (WARN_ON(oxfw->dev_lock_count <= 0)) in snd_oxfw_stream_lock_release()
894 if (--oxfw->dev_lock_count == 0) in snd_oxfw_stream_lock_release()
897 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()