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()
158 if (stream == &oxfw->tx_stream) { in init_stream()
159 conn = &oxfw->out_conn; in init_stream()
163 conn = &oxfw->in_conn; in init_stream()
168 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0); in init_stream()
172 err = amdtp_am824_init(stream, oxfw->unit, s_dir, CIP_NONBLOCKING); in init_stream()
179 * OXFW starts to transmit packets with non-zero dbc. in init_stream()
182 * blocks than IEC 61883-6 defines. in init_stream()
184 if (stream == &oxfw->tx_stream) { in init_stream()
185 oxfw->tx_stream.flags |= CIP_JUMBO_PAYLOAD; in init_stream()
186 if (oxfw->wrong_dbs) in init_stream()
187 oxfw->tx_stream.flags |= CIP_WRONG_DBS; in init_stream()
202 if (stream == &oxfw->rx_stream) { in keep_resources()
204 formats = oxfw->rx_stream_formats; in keep_resources()
205 conn = &oxfw->in_conn; in keep_resources()
208 formats = oxfw->tx_stream_formats; in keep_resources()
209 conn = &oxfw->out_conn; in keep_resources()
231 return -EINVAL; in keep_resources()
235 return -EINVAL; in keep_resources()
257 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
260 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
261 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
266 if (stream == &oxfw->tx_stream) in snd_oxfw_stream_reserve_duplex()
279 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_reserve_duplex()
281 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
282 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
284 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
285 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
286 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
290 if (oxfw->substreams_count == 0 || in snd_oxfw_stream_reserve_duplex()
294 dev_err(&oxfw->unit->device, in snd_oxfw_stream_reserve_duplex()
299 err = keep_resources(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_reserve_duplex()
303 if (oxfw->has_output) { in snd_oxfw_stream_reserve_duplex()
304 err = keep_resources(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_reserve_duplex()
306 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
311 err = amdtp_domain_set_events_per_period(&oxfw->domain, in snd_oxfw_stream_reserve_duplex()
314 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_reserve_duplex()
315 if (oxfw->has_output) in snd_oxfw_stream_reserve_duplex()
316 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_reserve_duplex()
328 if (oxfw->substreams_count == 0) in snd_oxfw_stream_start_duplex()
329 return -EIO; in snd_oxfw_stream_start_duplex()
331 if (amdtp_streaming_error(&oxfw->rx_stream) || in snd_oxfw_stream_start_duplex()
332 amdtp_streaming_error(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
333 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
335 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
336 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
337 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
340 if (!amdtp_stream_running(&oxfw->rx_stream)) { in snd_oxfw_stream_start_duplex()
341 err = start_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_start_duplex()
343 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
348 if (oxfw->has_output && in snd_oxfw_stream_start_duplex()
349 !amdtp_stream_running(&oxfw->tx_stream)) { in snd_oxfw_stream_start_duplex()
350 err = start_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_start_duplex()
352 dev_err(&oxfw->unit->device, in snd_oxfw_stream_start_duplex()
358 err = amdtp_domain_start(&oxfw->domain, 0); in snd_oxfw_stream_start_duplex()
363 if (!amdtp_stream_wait_callback(&oxfw->rx_stream, in snd_oxfw_stream_start_duplex()
365 err = -ETIMEDOUT; in snd_oxfw_stream_start_duplex()
369 if (oxfw->has_output) { in snd_oxfw_stream_start_duplex()
370 if (!amdtp_stream_wait_callback(&oxfw->tx_stream, in snd_oxfw_stream_start_duplex()
372 err = -ETIMEDOUT; in snd_oxfw_stream_start_duplex()
380 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_start_duplex()
382 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_start_duplex()
383 if (oxfw->has_output) in snd_oxfw_stream_start_duplex()
384 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_start_duplex()
391 if (oxfw->substreams_count == 0) { in snd_oxfw_stream_stop_duplex()
392 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_stop_duplex()
394 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
395 cmp_connection_release(&oxfw->in_conn); in snd_oxfw_stream_stop_duplex()
397 if (oxfw->has_output) { in snd_oxfw_stream_stop_duplex()
398 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
399 cmp_connection_release(&oxfw->out_conn); in snd_oxfw_stream_stop_duplex()
408 if (stream == &oxfw->tx_stream) in destroy_stream()
409 conn = &oxfw->out_conn; in destroy_stream()
411 conn = &oxfw->in_conn; in destroy_stream()
421 err = init_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
425 if (oxfw->has_output) { in snd_oxfw_stream_init_duplex()
426 err = init_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
428 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
433 err = amdtp_domain_init(&oxfw->domain); in snd_oxfw_stream_init_duplex()
435 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_init_duplex()
436 if (oxfw->has_output) in snd_oxfw_stream_init_duplex()
437 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_init_duplex()
447 amdtp_domain_destroy(&oxfw->domain); in snd_oxfw_stream_destroy_duplex()
449 destroy_stream(oxfw, &oxfw->rx_stream); in snd_oxfw_stream_destroy_duplex()
451 if (oxfw->has_output) in snd_oxfw_stream_destroy_duplex()
452 destroy_stream(oxfw, &oxfw->tx_stream); in snd_oxfw_stream_destroy_duplex()
457 amdtp_domain_stop(&oxfw->domain); in snd_oxfw_stream_update_duplex()
459 cmp_connection_break(&oxfw->in_conn); in snd_oxfw_stream_update_duplex()
461 amdtp_stream_pcm_abort(&oxfw->rx_stream); in snd_oxfw_stream_update_duplex()
463 if (oxfw->has_output) { in snd_oxfw_stream_update_duplex()
464 cmp_connection_break(&oxfw->out_conn); in snd_oxfw_stream_update_duplex()
466 amdtp_stream_pcm_abort(&oxfw->tx_stream); in snd_oxfw_stream_update_duplex()
481 return -ENOMEM; in snd_oxfw_stream_get_current_formation()
483 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len); in snd_oxfw_stream_get_current_formation()
487 err = -EIO; in snd_oxfw_stream_get_current_formation()
498 * See Table 6.16 - AM824 Stream Format
499 * Figure 6.19 - format_information field for AM824 Compound
501 * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
516 return -ENXIO; in snd_oxfw_stream_parse_format()
524 return -ENXIO; in snd_oxfw_stream_parse_format()
526 formation->rate = oxfw_rate_table[i]; in snd_oxfw_stream_parse_format()
533 /* IEC 60958 Conformant, currently handled as MBLA */ in snd_oxfw_stream_parse_format()
537 formation->pcm += channels; in snd_oxfw_stream_parse_format()
541 formation->midi = channels; in snd_oxfw_stream_parse_format()
543 /* IEC 61937-3 to 7 */ in snd_oxfw_stream_parse_format()
550 case 0x07: /* DVD-Audio */ in snd_oxfw_stream_parse_format()
557 /* SMPTE Time-Code conformant */ in snd_oxfw_stream_parse_format()
568 return -ENXIO; /* not supported */ in snd_oxfw_stream_parse_format()
572 if (formation->pcm > AM824_MAX_CHANNELS_FOR_PCM || in snd_oxfw_stream_parse_format()
573 formation->midi > AM824_MAX_CHANNELS_FOR_MIDI) in snd_oxfw_stream_parse_format()
574 return -ENXIO; in snd_oxfw_stream_parse_format()
589 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len); in assume_stream_formats()
591 dev_err(&oxfw->unit->device, in assume_stream_formats()
604 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
607 err = -ENOMEM; in assume_stream_formats()
616 err = avc_general_inquiry_sig_fmt(oxfw->unit, in assume_stream_formats()
623 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len, in assume_stream_formats()
626 err = -ENOMEM; in assume_stream_formats()
633 oxfw->assumed = true; in assume_stream_formats()
649 return -ENOMEM; in fill_stream_formats()
652 formats = oxfw->tx_stream_formats; in fill_stream_formats()
654 formats = oxfw->rx_stream_formats; in fill_stream_formats()
658 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0); in fill_stream_formats()
659 if (err == -ENXIO) { in fill_stream_formats()
666 dev_err(&oxfw->unit->device, in fill_stream_formats()
677 err = -EIO; in fill_stream_formats()
686 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len, in fill_stream_formats()
689 err = -ENOMEM; in fill_stream_formats()
695 err = avc_stream_get_format_list(oxfw->unit, dir, 0, in fill_stream_formats()
698 if (err == -EINVAL) { in fill_stream_formats()
702 dev_err(&oxfw->unit->device, in fill_stream_formats()
724 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs); in snd_oxfw_stream_discover()
726 dev_err(&oxfw->unit->device, in snd_oxfw_stream_discover()
731 err = -ENXIO; in snd_oxfw_stream_discover()
739 if (err != -ENXIO) in snd_oxfw_stream_discover()
746 format = oxfw->tx_stream_formats[i]; in snd_oxfw_stream_discover()
756 oxfw->midi_input_ports = 1; in snd_oxfw_stream_discover()
759 oxfw->has_output = true; in snd_oxfw_stream_discover()
767 if (err != -ENXIO) in snd_oxfw_stream_discover()
774 format = oxfw->rx_stream_formats[i]; in snd_oxfw_stream_discover()
784 oxfw->midi_output_ports = 1; in snd_oxfw_stream_discover()
787 oxfw->has_input = true; in snd_oxfw_stream_discover()
796 oxfw->dev_lock_changed = true; in snd_oxfw_stream_lock_changed()
797 wake_up(&oxfw->hwdep_wait); in snd_oxfw_stream_lock_changed()
804 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
807 if (oxfw->dev_lock_count < 0) { in snd_oxfw_stream_lock_try()
808 err = -EBUSY; in snd_oxfw_stream_lock_try()
813 if (oxfw->dev_lock_count++ == 0) in snd_oxfw_stream_lock_try()
817 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_try()
823 spin_lock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()
825 if (WARN_ON(oxfw->dev_lock_count <= 0)) in snd_oxfw_stream_lock_release()
827 if (--oxfw->dev_lock_count == 0) in snd_oxfw_stream_lock_release()
830 spin_unlock_irq(&oxfw->lock); in snd_oxfw_stream_lock_release()