Lines Matching +full:double +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0-only
3 * amdtp-dot.c - a part of driver for Digidesign Digi 002/003 family
5 * Copyright (c) 2014-2015 Takashi Sakamoto
15 /* 'Clock-based rate control mode' is just supported. */
34 * The double-oh-three algorithm was discovered by Robin Gareus and Damien
35 * Zammit in 2012, with reverse-engineering for Digi 003 Rack.
53 * double-oh-three look up table
55 * @param idx index byte (audio-sample data) 0x00..0xff
56 * @param off channel offset shift
66 * of the last non-zero data in dot_scrt()
85 * hir[] is not used and - coincidentally - the salt's hi nibble is in dot_scrt()
98 return ((nib[14 + off - len[ln]]) | (hr << 4)); in dot_scrt()
106 state->off = 0; in dot_encode_step()
107 state->idx = data[MAGIC_DOT_BYTE] ^ state->carry; in dot_encode_step()
109 data[MAGIC_DOT_BYTE] ^= state->carry; in dot_encode_step()
110 state->carry = dot_scrt(state->idx, ++(state->off)); in dot_encode_step()
116 struct amdtp_dot *p = s->protocol; in amdtp_dot_set_parameters()
120 return -EBUSY; in amdtp_dot_set_parameters()
123 * A first data channel is for MIDI messages, the rest is Multi Bit in amdtp_dot_set_parameters()
124 * Linear Audio data channel. in amdtp_dot_set_parameters()
130 s->ctx_data.rx.fdf = AMDTP_FDF_AM824 | s->sfc; in amdtp_dot_set_parameters()
132 p->pcm_channels = pcm_channels; in amdtp_dot_set_parameters()
140 p->midi_fifo_limit = rate - MIDI_BYTES_PER_SECOND * s->syt_interval + 1; in amdtp_dot_set_parameters()
149 struct amdtp_dot *p = s->protocol; in write_pcm_s32()
150 unsigned int channels = p->pcm_channels; in write_pcm_s32()
151 struct snd_pcm_runtime *runtime = pcm->runtime; in write_pcm_s32()
157 pcm_buffer_pointer = s->pcm_buffer_pointer + pcm_frames; in write_pcm_s32()
158 pcm_buffer_pointer %= runtime->buffer_size; in write_pcm_s32()
160 src = (void *)runtime->dma_area + in write_pcm_s32()
162 remaining_frames = runtime->buffer_size - pcm_buffer_pointer; in write_pcm_s32()
168 dot_encode_step(&p->state, &buffer[c]); in write_pcm_s32()
171 buffer += s->data_block_quadlets; in write_pcm_s32()
172 if (--remaining_frames == 0) in write_pcm_s32()
173 src = (void *)runtime->dma_area; in write_pcm_s32()
181 struct amdtp_dot *p = s->protocol; in read_pcm_s32()
182 unsigned int channels = p->pcm_channels; in read_pcm_s32()
183 struct snd_pcm_runtime *runtime = pcm->runtime; in read_pcm_s32()
189 pcm_buffer_pointer = s->pcm_buffer_pointer + pcm_frames; in read_pcm_s32()
190 pcm_buffer_pointer %= runtime->buffer_size; in read_pcm_s32()
192 dst = (void *)runtime->dma_area + in read_pcm_s32()
194 remaining_frames = runtime->buffer_size - pcm_buffer_pointer; in read_pcm_s32()
202 buffer += s->data_block_quadlets; in read_pcm_s32()
203 if (--remaining_frames == 0) in read_pcm_s32()
204 dst = (void *)runtime->dma_area; in read_pcm_s32()
211 struct amdtp_dot *p = s->protocol; in write_pcm_silence()
214 channels = p->pcm_channels; in write_pcm_silence()
220 buffer += s->data_block_quadlets; in write_pcm_silence()
226 struct amdtp_dot *p = s->protocol; in midi_ratelimit_per_packet()
229 used = p->midi_fifo_used[port]; in midi_ratelimit_per_packet()
233 used -= MIDI_BYTES_PER_SECOND * s->syt_interval; in midi_ratelimit_per_packet()
235 p->midi_fifo_used[port] = used; in midi_ratelimit_per_packet()
237 return used < p->midi_fifo_limit; in midi_ratelimit_per_packet()
243 struct amdtp_dot *p = s->protocol; in midi_use_bytes()
245 p->midi_fifo_used[port] += amdtp_rate_table[s->sfc] * count; in midi_use_bytes()
251 struct amdtp_dot *p = s->protocol; in write_midi_messages()
263 p->midi[port] != NULL) in write_midi_messages()
264 len = snd_rawmidi_transmit(p->midi[port], b + 1, 2); in write_midi_messages()
269 * - 0000b: physical MIDI port 1. in write_midi_messages()
270 * - 0010b: physical MIDI port 2. in write_midi_messages()
271 * - 1110b: console MIDI port. in write_midi_messages()
288 buffer += s->data_block_quadlets; in write_midi_messages()
295 struct amdtp_dot *p = s->protocol; in read_midi_messages()
306 * - 0000b: physical MIDI port 1. Use port 0. in read_midi_messages()
307 * - 1110b: console MIDI port. Use port 2. in read_midi_messages()
314 if (port < MAX_MIDI_PORTS && p->midi[port]) in read_midi_messages()
315 snd_rawmidi_receive(p->midi[port], b + 1, len); in read_midi_messages()
318 buffer += s->data_block_quadlets; in read_midi_messages()
327 /* This protocol delivers 24 bit data in 32bit data channel. */ in amdtp_dot_add_pcm_hw_constraints()
338 struct amdtp_dot *p = s->protocol; in amdtp_dot_midi_trigger()
341 WRITE_ONCE(p->midi[port], midi); in amdtp_dot_midi_trigger()
351 __be32 *buf = desc->ctx_payload; in process_ir_ctx_payloads()
352 unsigned int data_blocks = desc->data_blocks; in process_ir_ctx_payloads()
372 __be32 *buf = desc->ctx_payload; in process_it_ctx_payloads()
373 unsigned int data_blocks = desc->data_blocks; in process_it_ctx_payloads()
383 desc->data_block_counter); in process_it_ctx_payloads()
407 struct amdtp_dot *p = s->protocol; in amdtp_dot_reset()
409 p->state.carry = 0x00; in amdtp_dot_reset()
410 p->state.idx = 0x00; in amdtp_dot_reset()
411 p->state.off = 0; in amdtp_dot_reset()