Lines Matching +full:iec +full:- +full:61937

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()
181 conn = &oxfw->in_conn; in init_stream()
186 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0); in init_stream()
190 err = amdtp_am824_init(stream, oxfw->unit, s_dir, flags); in init_stream()
208 if (stream == &oxfw->rx_stream) { in keep_resources()
210 formats = oxfw->rx_stream_formats; in keep_resources()
211 conn = &oxfw->in_conn; in keep_resources()
214 formats = oxfw->tx_stream_formats; in keep_resources()
215 conn = &oxfw->out_conn; in keep_resources()
237 return -EINVAL; in keep_resources()
241 return -EINVAL; in keep_resources()
263 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
266 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
267 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
272 if (stream == &oxfw->tx_stream) in snd_oxfw_stream_reserve_duplex()
285 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_reserve_duplex()
287 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
288 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
290 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
291 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
292 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
296 if (oxfw->substreams_count == 0 || in snd_oxfw_stream_reserve_duplex()
300 dev_err(&oxfw->unit->device, in snd_oxfw_stream_reserve_duplex()
305 err = keep_resources(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
309 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
310 err = keep_resources(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
312 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
317 err = amdtp_domain_set_events_per_period(&oxfw->domain, in snd_oxfw_stream_reserve_duplex()
320 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
321 if (oxfw->has_output) in snd_oxfw_stream_reserve_duplex()
322 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
334 if (oxfw->substreams_count == 0) in snd_oxfw_stream_start_duplex()
335 return -EIO; in snd_oxfw_stream_start_duplex()
337 if (amdtp_streaming_error(&oxfw->rx_stream) || in snd_oxfw_stream_start_duplex()
338 amdtp_streaming_error(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
339 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
341 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
342 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
343 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
346 if (!amdtp_stream_running(&oxfw->rx_stream)) { in snd_oxfw_stream_start_duplex()
350 err = start_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_start_duplex()
352 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
357 if (oxfw->has_output && in snd_oxfw_stream_start_duplex()
358 !amdtp_stream_running(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
359 err = start_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_start_duplex()
361 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
366 if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD) { in snd_oxfw_stream_start_duplex()
370 } else if (oxfw->quirks & SND_OXFW_QUIRK_VOLUNTARY_RECOVERY) { in snd_oxfw_stream_start_duplex()
383 err = amdtp_domain_start(&oxfw->domain, tx_init_skip_cycles, replay_seq, false); in snd_oxfw_stream_start_duplex()
387 if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) { in snd_oxfw_stream_start_duplex()
388 err = -ETIMEDOUT; in snd_oxfw_stream_start_duplex()
395 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
397 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
398 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
399 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
406 if (oxfw->substreams_count == 0) { in snd_oxfw_stream_stop_duplex()
407 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_stop_duplex()
409 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
410 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
412 if (oxfw->has_output) { in snd_oxfw_stream_stop_duplex()
413 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
414 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
423 if (stream == &oxfw->tx_stream) in destroy_stream()
424 conn = &oxfw->out_conn; in destroy_stream()
426 conn = &oxfw->in_conn; in destroy_stream()
436 err = init_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
440 if (oxfw->has_output) { in snd_oxfw_stream_init_duplex()
441 err = init_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
443 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
448 err = amdtp_domain_init(&oxfw->domain); in snd_oxfw_stream_init_duplex()
450 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
451 if (oxfw->has_output) in snd_oxfw_stream_init_duplex()
452 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
462 amdtp_domain_destroy(&oxfw->domain); in snd_oxfw_stream_destroy_duplex()
464 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_destroy_duplex()
466 if (oxfw->has_output) in snd_oxfw_stream_destroy_duplex()
467 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_destroy_duplex()
472 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_update_duplex()
474 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_update_duplex()
476 amdtp_stream_pcm_abort(&oxfw->rx_stream); in snd_oxfw_stream_update_duplex()
478 if (oxfw->has_output) { in snd_oxfw_stream_update_duplex()
479 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_update_duplex()
481 amdtp_stream_pcm_abort(&oxfw->tx_stream); in snd_oxfw_stream_update_duplex()
496 return -ENOMEM; in snd_oxfw_stream_get_current_formation()
498 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len); in snd_oxfw_stream_get_current_formation()
502 err = -EIO; in snd_oxfw_stream_get_current_formation()
513 * See Table 6.16 - AM824 Stream Format
514 * Figure 6.19 - format_information field for AM824 Compound
516 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
531 return -ENXIO; in snd_oxfw_stream_parse_format()
539 return -ENXIO; in snd_oxfw_stream_parse_format()
541 formation->rate = oxfw_rate_table[i]; in snd_oxfw_stream_parse_format()
548 /* IEC 60958 Conformant, currently handled as MBLA */ in snd_oxfw_stream_parse_format()
552 formation->pcm += channels; in snd_oxfw_stream_parse_format()
556 formation->midi = channels; in snd_oxfw_stream_parse_format()
558 /* IEC 61937-3 to 7 */ in snd_oxfw_stream_parse_format()
565 case 0x07: /* DVD-Audio */ in snd_oxfw_stream_parse_format()
572 /* SMPTE Time-Code conformant */ in snd_oxfw_stream_parse_format()
583 return -ENXIO; /* not supported */ in snd_oxfw_stream_parse_format()
587 if (formation->pcm > AM824_MAX_CHANNELS_FOR_PCM || in snd_oxfw_stream_parse_format()
588 formation->midi > AM824_MAX_CHANNELS_FOR_MIDI) in snd_oxfw_stream_parse_format()
589 return -ENXIO; in snd_oxfw_stream_parse_format()
604 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len); in assume_stream_formats()
606 dev_err(&oxfw->unit->device, in assume_stream_formats()
619 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
622 err = -ENOMEM; in assume_stream_formats()
631 err = avc_general_inquiry_sig_fmt(oxfw->unit, in assume_stream_formats()
638 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
641 err = -ENOMEM; in assume_stream_formats()
648 oxfw->assumed = true; in assume_stream_formats()
664 return -ENOMEM; in fill_stream_formats()
667 formats = oxfw->tx_stream_formats; in fill_stream_formats()
669 formats = oxfw->rx_stream_formats; in fill_stream_formats()
673 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0); in fill_stream_formats()
674 if (err == -ENXIO) { in fill_stream_formats()
681 dev_err(&oxfw->unit->device, in fill_stream_formats()
692 err = -EIO; in fill_stream_formats()
701 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len, in fill_stream_formats()
704 err = -ENOMEM; in fill_stream_formats()
710 err = avc_stream_get_format_list(oxfw->unit, dir, 0, in fill_stream_formats()
713 if (err == -EINVAL) { in fill_stream_formats()
717 dev_err(&oxfw->unit->device, in fill_stream_formats()
739 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs); in snd_oxfw_stream_discover()
741 dev_err(&oxfw->unit->device, in snd_oxfw_stream_discover()
746 err = -ENXIO; in snd_oxfw_stream_discover()
754 if (err != -ENXIO) in snd_oxfw_stream_discover()
761 format = oxfw->tx_stream_formats[i]; in snd_oxfw_stream_discover()
771 oxfw->midi_input_ports = 1; in snd_oxfw_stream_discover()
774 oxfw->has_output = true; in snd_oxfw_stream_discover()
782 if (err != -ENXIO) in snd_oxfw_stream_discover()
789 format = oxfw->rx_stream_formats[i]; in snd_oxfw_stream_discover()
799 oxfw->midi_output_ports = 1; in snd_oxfw_stream_discover()
802 oxfw->has_input = true; in snd_oxfw_stream_discover()
811 oxfw->dev_lock_changed = true; in snd_oxfw_stream_lock_changed()
812 wake_up(&oxfw->hwdep_wait); in snd_oxfw_stream_lock_changed()
819 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
822 if (oxfw->dev_lock_count < 0) { in snd_oxfw_stream_lock_try()
823 err = -EBUSY; in snd_oxfw_stream_lock_try()
828 if (oxfw->dev_lock_count++ == 0) in snd_oxfw_stream_lock_try()
832 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
838 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()
840 if (WARN_ON(oxfw->dev_lock_count <= 0)) in snd_oxfw_stream_lock_release()
842 if (--oxfw->dev_lock_count == 0) in snd_oxfw_stream_lock_release()
845 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()