Lines Matching defs:oxfw
8 #include "oxfw.h"
41 static int set_rate(struct snd_oxfw *oxfw, unsigned int rate)
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,
57 static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s,
66 if (s == &oxfw->tx_stream) {
67 formats = oxfw->tx_stream_formats;
70 formats = oxfw->rx_stream_formats;
87 if (oxfw->assumed)
88 return set_rate(oxfw, rate);
93 err = avc_stream_set_format(oxfw->unit, dir, 0, formats[i], len);
103 static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
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,
127 static int check_connection_used_by_others(struct snd_oxfw *oxfw,
134 if (stream == &oxfw->tx_stream)
135 conn = &oxfw->out_conn;
137 conn = &oxfw->in_conn;
141 dev_err(&oxfw->unit->device,
151 static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
158 if (stream == &oxfw->tx_stream) {
159 conn = &oxfw->out_conn;
163 conn = &oxfw->in_conn;
168 err = cmp_connection_init(conn, oxfw->unit, c_dir, 0);
172 err = amdtp_am824_init(stream, oxfw->unit, s_dir, CIP_NONBLOCKING);
184 if (stream == &oxfw->tx_stream) {
185 oxfw->tx_stream.flags |= CIP_JUMBO_PAYLOAD;
186 if (oxfw->wrong_dbs)
187 oxfw->tx_stream.flags |= CIP_WRONG_DBS;
193 static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
202 if (stream == &oxfw->rx_stream) {
204 formats = oxfw->rx_stream_formats;
205 conn = &oxfw->in_conn;
208 formats = oxfw->tx_stream_formats;
209 conn = &oxfw->out_conn;
212 err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation);
245 int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
257 err = check_connection_used_by_others(oxfw, &oxfw->rx_stream);
260 if (oxfw->has_output) {
261 err = check_connection_used_by_others(oxfw, &oxfw->tx_stream);
266 if (stream == &oxfw->tx_stream)
271 err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation);
279 amdtp_domain_stop(&oxfw->domain);
281 cmp_connection_break(&oxfw->in_conn);
282 cmp_connection_release(&oxfw->in_conn);
284 if (oxfw->has_output) {
285 cmp_connection_break(&oxfw->out_conn);
286 cmp_connection_release(&oxfw->out_conn);
290 if (oxfw->substreams_count == 0 ||
292 err = set_stream_format(oxfw, stream, rate, pcm_channels);
294 dev_err(&oxfw->unit->device,
299 err = keep_resources(oxfw, &oxfw->rx_stream);
303 if (oxfw->has_output) {
304 err = keep_resources(oxfw, &oxfw->tx_stream);
306 cmp_connection_release(&oxfw->in_conn);
311 err = amdtp_domain_set_events_per_period(&oxfw->domain,
314 cmp_connection_release(&oxfw->in_conn);
315 if (oxfw->has_output)
316 cmp_connection_release(&oxfw->out_conn);
324 int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw)
328 if (oxfw->substreams_count == 0)
331 if (amdtp_streaming_error(&oxfw->rx_stream) ||
332 amdtp_streaming_error(&oxfw->tx_stream)) {
333 amdtp_domain_stop(&oxfw->domain);
335 cmp_connection_break(&oxfw->in_conn);
336 if (oxfw->has_output)
337 cmp_connection_break(&oxfw->out_conn);
340 if (!amdtp_stream_running(&oxfw->rx_stream)) {
341 err = start_stream(oxfw, &oxfw->rx_stream);
343 dev_err(&oxfw->unit->device,
348 if (oxfw->has_output &&
349 !amdtp_stream_running(&oxfw->tx_stream)) {
350 err = start_stream(oxfw, &oxfw->tx_stream);
352 dev_err(&oxfw->unit->device,
358 err = amdtp_domain_start(&oxfw->domain, 0);
363 if (!amdtp_stream_wait_callback(&oxfw->rx_stream,
369 if (oxfw->has_output) {
370 if (!amdtp_stream_wait_callback(&oxfw->tx_stream,
380 amdtp_domain_stop(&oxfw->domain);
382 cmp_connection_break(&oxfw->in_conn);
383 if (oxfw->has_output)
384 cmp_connection_break(&oxfw->out_conn);
389 void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw)
391 if (oxfw->substreams_count == 0) {
392 amdtp_domain_stop(&oxfw->domain);
394 cmp_connection_break(&oxfw->in_conn);
395 cmp_connection_release(&oxfw->in_conn);
397 if (oxfw->has_output) {
398 cmp_connection_break(&oxfw->out_conn);
399 cmp_connection_release(&oxfw->out_conn);
404 static void destroy_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
408 if (stream == &oxfw->tx_stream)
409 conn = &oxfw->out_conn;
411 conn = &oxfw->in_conn;
417 int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw)
421 err = init_stream(oxfw, &oxfw->rx_stream);
425 if (oxfw->has_output) {
426 err = init_stream(oxfw, &oxfw->tx_stream);
428 destroy_stream(oxfw, &oxfw->rx_stream);
433 err = amdtp_domain_init(&oxfw->domain);
435 destroy_stream(oxfw, &oxfw->rx_stream);
436 if (oxfw->has_output)
437 destroy_stream(oxfw, &oxfw->tx_stream);
445 void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw)
447 amdtp_domain_destroy(&oxfw->domain);
449 destroy_stream(oxfw, &oxfw->rx_stream);
451 if (oxfw->has_output)
452 destroy_stream(oxfw, &oxfw->tx_stream);
455 void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw)
457 amdtp_domain_stop(&oxfw->domain);
459 cmp_connection_break(&oxfw->in_conn);
461 amdtp_stream_pcm_abort(&oxfw->rx_stream);
463 if (oxfw->has_output) {
464 cmp_connection_break(&oxfw->out_conn);
466 amdtp_stream_pcm_abort(&oxfw->tx_stream);
470 int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
483 err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len);
580 assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
589 err = avc_stream_get_format_single(oxfw->unit, dir, pid, buf, len);
591 dev_err(&oxfw->unit->device,
604 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
616 err = avc_general_inquiry_sig_fmt(oxfw->unit,
623 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
633 oxfw->assumed = true;
638 static int fill_stream_formats(struct snd_oxfw *oxfw,
652 formats = oxfw->tx_stream_formats;
654 formats = oxfw->rx_stream_formats;
658 err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0);
662 err = assume_stream_formats(oxfw, dir, pid, buf, &len,
666 dev_err(&oxfw->unit->device,
686 formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len,
695 err = avc_stream_get_format_list(oxfw->unit, dir, 0,
702 dev_err(&oxfw->unit->device,
715 int snd_oxfw_stream_discover(struct snd_oxfw *oxfw)
724 err = avc_general_get_plug_info(oxfw->unit, 0x1f, 0x07, 0x00, plugs);
726 dev_err(&oxfw->unit->device,
737 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0);
746 format = oxfw->tx_stream_formats[i];
756 oxfw->midi_input_ports = 1;
759 oxfw->has_output = true;
765 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0);
774 format = oxfw->rx_stream_formats[i];
784 oxfw->midi_output_ports = 1;
787 oxfw->has_input = true;
794 void snd_oxfw_stream_lock_changed(struct snd_oxfw *oxfw)
796 oxfw->dev_lock_changed = true;
797 wake_up(&oxfw->hwdep_wait);
800 int snd_oxfw_stream_lock_try(struct snd_oxfw *oxfw)
804 spin_lock_irq(&oxfw->lock);
807 if (oxfw->dev_lock_count < 0) {
813 if (oxfw->dev_lock_count++ == 0)
814 snd_oxfw_stream_lock_changed(oxfw);
817 spin_unlock_irq(&oxfw->lock);
821 void snd_oxfw_stream_lock_release(struct snd_oxfw *oxfw)
823 spin_lock_irq(&oxfw->lock);
825 if (WARN_ON(oxfw->dev_lock_count <= 0))
827 if (--oxfw->dev_lock_count == 0)
828 snd_oxfw_stream_lock_changed(oxfw);
830 spin_unlock_irq(&oxfw->lock);