Lines Matching +full:reg +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0-only
2 // motu-protocol-v1.c - a part of driver for MOTU FireWire series
4 // Copyright (c) 2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>
12 // 0xffff0000: ISOC_COMM_CONTROL_MASK in motu-stream.c.
20 // 0x00000800: analog-1/2
21 // 0x00001a00: analog-3/4
22 // 0x00002c00: analog-5/6
23 // 0x00003e00: analog-7/8
24 // 0x00000000: analog-1
25 // 0x00000900: analog-2
26 // 0x00001200: analog-3
27 // 0x00001b00: analog-4
28 // 0x00002400: analog-5
29 // 0x00002d00: analog-6
30 // 0x00003600: analog-7
31 // 0x00003f00: analog-8
76 // 0x00004800: analog-1/2
77 // 0x00005a00: analog-3/4
78 // 0x00006c00: analog-5/6
79 // 0x00007e00: analog-7/8
80 // 0x00104800: AES/EBU-1/2
81 // 0x00004000: analog-1
82 // 0x00004900: analog-2
83 // 0x00005200: analog-3
84 // 0x00005b00: analog-4
85 // 0x00006400: analog-5
86 // 0x00006d00: analog-6
87 // 0x00007600: analog-7
88 // 0x00007f00: analog-8
89 // 0x00104000: AES/EBU-1
90 // 0x00104900: AES/EBU-2
125 static void parse_clock_rate_828(u32 data, unsigned int *rate) in parse_clock_rate_828() argument
127 if (data & CLK_828_STATUS_FLAG_RATE_48000) in parse_clock_rate_828()
135 __be32 reg; in get_clock_rate_828() local
138 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in get_clock_rate_828()
141 parse_clock_rate_828(be32_to_cpu(reg), rate); in get_clock_rate_828()
146 static int parse_clock_rate_896(u32 data, unsigned int *rate) in parse_clock_rate_896() argument
148 switch (data & CLK_896_STATUS_MASK_RATE) { in parse_clock_rate_896()
162 return -ENXIO; in parse_clock_rate_896()
170 __be32 reg; in get_clock_rate_896() local
173 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in get_clock_rate_896()
176 return parse_clock_rate_896(be32_to_cpu(reg), rate); in get_clock_rate_896()
181 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_get_clock_rate()
183 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_get_clock_rate()
186 return -ENXIO; in snd_motu_protocol_v1_get_clock_rate()
191 __be32 reg; in set_clock_rate_828() local
192 u32 data; in set_clock_rate_828() local
195 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in set_clock_rate_828()
198 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in set_clock_rate_828()
200 data &= ~CLK_828_STATUS_FLAG_RATE_48000; in set_clock_rate_828()
202 data |= CLK_828_STATUS_FLAG_RATE_48000; in set_clock_rate_828()
204 reg = cpu_to_be32(data); in set_clock_rate_828()
205 return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in set_clock_rate_828()
211 __be32 reg; in set_clock_rate_896() local
212 u32 data; in set_clock_rate_896() local
215 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in set_clock_rate_896()
218 data = be32_to_cpu(reg); in set_clock_rate_896()
234 return -EINVAL; in set_clock_rate_896()
237 data &= ~CLK_896_STATUS_MASK_RATE; in set_clock_rate_896()
238 data |= flag; in set_clock_rate_896()
240 reg = cpu_to_be32(data); in set_clock_rate_896()
241 return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in set_clock_rate_896()
246 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_set_clock_rate()
248 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_set_clock_rate()
251 return -ENXIO; in snd_motu_protocol_v1_set_clock_rate()
256 __be32 reg; in get_clock_source_828() local
257 u32 data; in get_clock_source_828() local
260 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in get_clock_source_828()
263 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in get_clock_source_828()
265 switch (data & CLK_828_STATUS_MASK_SRC) { in get_clock_source_828()
274 if (data & CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF) in get_clock_source_828()
287 return -ENXIO; in get_clock_source_828()
295 __be32 reg; in get_clock_source_896() local
296 u32 data; in get_clock_source_896() local
299 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in get_clock_source_896()
302 data = be32_to_cpu(reg); in get_clock_source_896()
304 switch (data & CLK_896_STATUS_MASK_SRC) { in get_clock_source_896()
324 return -ENXIO; in get_clock_source_896()
332 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_get_clock_source()
334 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_get_clock_source()
337 return -ENXIO; in snd_motu_protocol_v1_get_clock_source()
342 __be32 reg; in switch_fetching_mode_828() local
343 u32 data; in switch_fetching_mode_828() local
346 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in switch_fetching_mode_828()
349 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in switch_fetching_mode_828()
351 data &= ~(CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT); in switch_fetching_mode_828()
357 data |= CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT; in switch_fetching_mode_828()
360 reg = cpu_to_be32(data); in switch_fetching_mode_828()
361 return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in switch_fetching_mode_828()
366 __be32 reg; in switch_fetching_mode_896() local
367 u32 data; in switch_fetching_mode_896() local
370 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in switch_fetching_mode_896()
373 data = be32_to_cpu(reg); in switch_fetching_mode_896()
375 data &= ~CLK_896_STATUS_FLAG_FETCH_ENABLE; in switch_fetching_mode_896()
377 data |= CLK_896_STATUS_FLAG_FETCH_ENABLE | CLK_896_STATUS_FLAG_OUTPUT_ON; in switch_fetching_mode_896()
379 reg = cpu_to_be32(data); in switch_fetching_mode_896()
380 return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg)); in switch_fetching_mode_896()
385 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_switch_fetching_mode()
387 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_switch_fetching_mode()
390 return -ENXIO; in snd_motu_protocol_v1_switch_fetching_mode()
395 __be32 reg; in detect_packet_formats_828() local
396 u32 data; in detect_packet_formats_828() local
399 motu->tx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_828()
400 motu->tx_packet_formats.msg_chunks = 2; in detect_packet_formats_828()
402 motu->rx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_828()
403 motu->rx_packet_formats.msg_chunks = 0; in detect_packet_formats_828()
405 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg)); in detect_packet_formats_828()
408 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in detect_packet_formats_828()
411 if (!(data & CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF)) in detect_packet_formats_828()
412 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_828()
414 if (!(data & CLK_828_STATUS_FLAG_OPT_OUT_IFACE_IS_SPDIF)) in detect_packet_formats_828()
415 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_828()
423 motu->tx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_896()
424 motu->rx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_896()
426 // No message chunk in data block. in detect_packet_formats_896()
427 motu->tx_packet_formats.msg_chunks = 0; in detect_packet_formats_896()
428 motu->rx_packet_formats.msg_chunks = 0; in detect_packet_formats_896()
432 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_896()
433 motu->tx_packet_formats.pcm_chunks[1] += 8; in detect_packet_formats_896()
435 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_896()
436 motu->rx_packet_formats.pcm_chunks[1] += 8; in detect_packet_formats_896()
443 memcpy(motu->tx_packet_formats.pcm_chunks, motu->spec->tx_fixed_pcm_chunks, in snd_motu_protocol_v1_cache_packet_formats()
444 sizeof(motu->tx_packet_formats.pcm_chunks)); in snd_motu_protocol_v1_cache_packet_formats()
445 memcpy(motu->rx_packet_formats.pcm_chunks, motu->spec->rx_fixed_pcm_chunks, in snd_motu_protocol_v1_cache_packet_formats()
446 sizeof(motu->rx_packet_formats.pcm_chunks)); in snd_motu_protocol_v1_cache_packet_formats()
448 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_cache_packet_formats()
450 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_cache_packet_formats()