Lines Matching +full:quad +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0
2 // ff-protocol-former.c - a part of driver for RME Fireface series
46 if ((data & 0x0000001e) == rate_entry->mask) { in parse_clock_bits()
47 *rate = rate_entry->rate; in parse_clock_bits()
52 return -EIO; in parse_clock_bits()
59 if ((data & 0x00001c00) == clk_entry->mask) { in parse_clock_bits()
60 *src = clk_entry->src; in parse_clock_bits()
65 return -EIO; in parse_clock_bits()
78 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST, in former_get_clock()
96 count = max(count, ff->spec->pcm_playback_channels[i]); in former_switch_fetching_mode()
100 return -ENOMEM; in former_switch_fetching_mode()
114 err = snd_fw_transaction(ff->unit, TCODE_WRITE_BLOCK_REQUEST, in former_switch_fetching_mode()
130 err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST, in dump_clock_config()
200 err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST, in dump_sync_status()
213 if (data[0] & clk_entry->locked_mask) { in dump_sync_status()
214 if (data[0] & clk_entry->synced_mask) in dump_sync_status()
222 snd_iprintf(buffer, "%s: %s\n", clk_entry->label, state); in dump_sync_status()
235 if ((data[0] & 0x1e0000) == referred_entry->mask) { in dump_sync_status()
236 label = referred_entry->label; in dump_sync_status()
245 if ((data[0] & 0x1e000000) == rate_entry->mask) { in dump_sync_status()
246 rate = rate_entry->rate; in dump_sync_status()
268 u8 *buf = (u8 *)ff->msg_buf[port]; in former_fill_midi_msg()
278 for (i = len - 1; i >= 0; --i) in former_fill_midi_msg()
279 ff->msg_buf[port][i] = cpu_to_le32(buf[i]); in former_fill_midi_msg()
280 ff->rx_bytes[port] = len; in former_fill_midi_msg()
301 reg = cpu_to_le32(ff->tx_stream.data_block_quadlets); in allocate_tx_resources()
302 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in allocate_tx_resources()
311 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST, in allocate_tx_resources()
325 return -ETIMEDOUT; in allocate_tx_resources()
328 // channel. On the other hand, 'struct fw_iso_resources.allocated' is in allocate_tx_resources()
330 ff->tx_resources.channel = tx_isoc_channel; in allocate_tx_resources()
342 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff800_allocate_resources()
353 err = fw_iso_resources_allocate(&ff->rx_resources, in ff800_allocate_resources()
354 amdtp_stream_get_max_payload(&ff->rx_stream), in ff800_allocate_resources()
355 fw_parent_device(ff->unit)->max_speed); in ff800_allocate_resources()
359 // Set isochronous channel and the number of quadlets of rx packets. in ff800_allocate_resources()
362 data = ff->rx_stream.data_block_quadlets << 3; in ff800_allocate_resources()
363 data = (data << 8) | ff->rx_resources.channel; in ff800_allocate_resources()
365 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff800_allocate_resources()
375 unsigned int generation = ff->rx_resources.generation; in ff800_begin_session()
378 if (generation != fw_parent_device(ff->unit)->card->generation) { in ff800_begin_session()
379 int err = fw_iso_resources_update(&ff->rx_resources); in ff800_begin_session()
385 reg |= cpu_to_le32(ff->tx_stream.data_block_quadlets); in ff800_begin_session()
386 if (fw_parent_device(ff->unit)->max_speed == SCODE_800) in ff800_begin_session()
388 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff800_begin_session()
397 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff800_finish_session()
414 substream = READ_ONCE(ff->tx_midi_substreams[0]); in ff800_handle_midi_msg()
437 // Fireface 400 manages isochronous channel number in 3 bit field. Therefore,
438 // we can allocate between 0 and 7 channel.
452 return -EINVAL; in ff400_allocate_resources()
456 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff400_allocate_resources()
467 // Keep resources for in-stream. in ff400_allocate_resources()
468 ff->tx_resources.channels_mask = 0x00000000000000ffuLL; in ff400_allocate_resources()
469 err = fw_iso_resources_allocate(&ff->tx_resources, in ff400_allocate_resources()
470 amdtp_stream_get_max_payload(&ff->tx_stream), in ff400_allocate_resources()
471 fw_parent_device(ff->unit)->max_speed); in ff400_allocate_resources()
475 // Keep resources for out-stream. in ff400_allocate_resources()
476 ff->rx_resources.channels_mask = 0x00000000000000ffuLL; in ff400_allocate_resources()
477 err = fw_iso_resources_allocate(&ff->rx_resources, in ff400_allocate_resources()
478 amdtp_stream_get_max_payload(&ff->rx_stream), in ff400_allocate_resources()
479 fw_parent_device(ff->unit)->max_speed); in ff400_allocate_resources()
481 fw_iso_resources_free(&ff->tx_resources); in ff400_allocate_resources()
488 unsigned int generation = ff->rx_resources.generation; in ff400_begin_session()
492 if (generation != fw_parent_device(ff->unit)->card->generation) { in ff400_begin_session()
493 err = fw_iso_resources_update(&ff->tx_resources); in ff400_begin_session()
497 err = fw_iso_resources_update(&ff->rx_resources); in ff400_begin_session()
502 // Set isochronous channel and the number of quadlets of received in ff400_begin_session()
504 reg = cpu_to_le32(((ff->rx_stream.data_block_quadlets << 3) << 8) | in ff400_begin_session()
505 ff->rx_resources.channel); in ff400_begin_session()
506 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff400_begin_session()
511 // Set isochronous channel and the number of quadlets of transmitted in ff400_begin_session()
515 (ff->tx_resources.channel << 5) | in ff400_begin_session()
516 (ff->tx_stream.data_block_quadlets)); in ff400_begin_session()
517 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff400_begin_session()
524 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff400_begin_session()
533 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, in ff400_finish_session()
537 static void parse_midi_msg(struct snd_ff *ff, u32 quad, unsigned int port) in parse_midi_msg() argument
539 struct snd_rawmidi_substream *substream = READ_ONCE(ff->tx_midi_substreams[port]); in parse_midi_msg()
542 u8 byte = (quad >> (16 * port)) & 0x000000ff; in parse_midi_msg()
561 struct ff400_msg_parser *parser = ff->msg_parser; in ff400_has_msg()
563 return (parser->push_pos != parser->pull_pos); in ff400_has_msg()
571 // - 0x04000000: 0x'....'....'0000'0000
572 // - 0x08000000: 0x'....'....'0000'0080
573 // - 0x10000000: 0x'....'....'0000'0100
574 // - 0x20000000: 0x'....'....'0000'0180
578 // - 0x01000000: suppress transmission
579 // - 0x02000000: suppress transmission
581 // Actually, the register is write-only and includes the other options such as
588 // - 0: Microphone input 0/1
589 // - 1: Line input 0/1
590 // - [2-4]: Line output 0-5
591 // - 5: Headphone output 0/1
592 // - 6: S/PDIF output 0/1
593 // - [7-10]: ADAT output 0-7
598 // - 0: 0.0 dB
599 // - 10: +10.0 dB
600 // - 11: +11.0 dB
601 // - 12: +12.0 dB
602 // - ...
603 // - 63: +63.0 dB:
604 // - 64: +64.0 dB:
605 // - 65: +65.0 dB:
609 // - 0: 0.0 dB
610 // - 1: +0.5 dB
611 // - 2: +1.0 dB
612 // - 3: +1.5 dB
613 // - ...
614 // - 34: +17.0 dB:
615 // - 35: +17.5 dB:
616 // - 36: +18.0 dB:
620 // - 63: -infinite
621 // - 62: -58.0 dB
622 // - 61: -56.0 dB
623 // - 60: -54.0 dB
624 // - 59: -53.0 dB
625 // - 58: -52.0 dB
626 // - ...
627 // - 7: -1.0 dB
628 // - 6: 0.0 dB
629 // - 5: +1.0 dB
630 // - ...
631 // - 2: +4.0 dB
632 // - 1: +5.0 dB
633 // - 0: +6.0 dB
655 u32 quad = le32_to_cpu(buf[i]); in ff400_handle_msg() local
657 if (quad & FF400_MSG_FLAG_IS_SIGNAL_LEVEL) { in ff400_handle_msg()
658 struct ff400_msg_parser *parser = ff->msg_parser; in ff400_handle_msg()
660 parser->msgs[parser->push_pos].msg = quad; in ff400_handle_msg()
661 parser->msgs[parser->push_pos].tstamp = tstamp; in ff400_handle_msg()
662 ++parser->push_pos; in ff400_handle_msg()
663 if (parser->push_pos >= FF400_QUEUE_SIZE) in ff400_handle_msg()
664 parser->push_pos = 0; in ff400_handle_msg()
667 } else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0) { in ff400_handle_msg()
668 parse_midi_msg(ff, quad, 0); in ff400_handle_msg()
669 } else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1) { in ff400_handle_msg()
670 parse_midi_msg(ff, quad, 1); in ff400_handle_msg()
675 wake_up(&ff->hwdep_wait); in ff400_handle_msg()
684 struct ff400_msg_parser *parser = ff->msg_parser; in ff400_copy_msg_to_user()
688 if (count < sizeof(ev) || parser->pull_pos == parser->push_pos) in ff400_copy_msg_to_user()
691 count -= sizeof(ev); in ff400_copy_msg_to_user()
694 while (count >= sizeof(*parser->msgs) && parser->pull_pos != parser->push_pos) { in ff400_copy_msg_to_user()
695 spin_unlock_irq(&ff->lock); in ff400_copy_msg_to_user()
696 if (copy_to_user(buf + consumed, parser->msgs + parser->pull_pos, in ff400_copy_msg_to_user()
697 sizeof(*parser->msgs))) in ff400_copy_msg_to_user()
698 ret = -EFAULT; in ff400_copy_msg_to_user()
699 spin_lock_irq(&ff->lock); in ff400_copy_msg_to_user()
703 ++parser->pull_pos; in ff400_copy_msg_to_user()
704 if (parser->pull_pos >= FF400_QUEUE_SIZE) in ff400_copy_msg_to_user()
705 parser->pull_pos = 0; in ff400_copy_msg_to_user()
707 count -= sizeof(*parser->msgs); in ff400_copy_msg_to_user()
708 consumed += sizeof(*parser->msgs); in ff400_copy_msg_to_user()
711 spin_unlock_irq(&ff->lock); in ff400_copy_msg_to_user()
713 ret = -EFAULT; in ff400_copy_msg_to_user()
714 spin_lock_irq(&ff->lock); in ff400_copy_msg_to_user()