Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
3 // motu-protocol-v1.c - a part of driver for MOTU FireWire series
5 // Copyright (c) 2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>
15 // 0xffff0000: ISOC_COMM_CONTROL_MASK in motu-stream.c.
23 // 0x00000800: analog-1/2
24 // 0x00001a00: analog-3/4
25 // 0x00002c00: analog-5/6
26 // 0x00003e00: analog-7/8
27 // 0x00000000: analog-1
28 // 0x00000900: analog-2
29 // 0x00001200: analog-3
30 // 0x00001b00: analog-4
31 // 0x00002400: analog-5
32 // 0x00002d00: analog-6
33 // 0x00003600: analog-7
34 // 0x00003f00: analog-8
79 // 0x00004800: analog-1/2
80 // 0x00005a00: analog-3/4
81 // 0x00006c00: analog-5/6
82 // 0x00007e00: analog-7/8
83 // 0x00104800: AES/EBU-1/2
84 // 0x00004000: analog-1
85 // 0x00004900: analog-2
86 // 0x00005200: analog-3
87 // 0x00005b00: analog-4
88 // 0x00006400: analog-5
89 // 0x00006d00: analog-6
90 // 0x00007600: analog-7
91 // 0x00007f00: analog-8
92 // 0x00104000: AES/EBU-1
93 // 0x00104900: AES/EBU-2
128 static void parse_clock_rate_828(u32 data, unsigned int *rate) in parse_clock_rate_828() argument
130 if (data & CLK_828_STATUS_FLAG_RATE_48000) in parse_clock_rate_828()
138 __be32 reg; in get_clock_rate_828() local
141 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in get_clock_rate_828()
144 parse_clock_rate_828(be32_to_cpu(reg), rate); in get_clock_rate_828()
149 static int parse_clock_rate_896(u32 data, unsigned int *rate) in parse_clock_rate_896() argument
151 switch (data & CLK_896_STATUS_MASK_RATE) { in parse_clock_rate_896()
165 return -ENXIO; in parse_clock_rate_896()
173 __be32 reg; in get_clock_rate_896() local
176 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in get_clock_rate_896()
179 return parse_clock_rate_896(be32_to_cpu(reg), rate); in get_clock_rate_896()
184 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_get_clock_rate()
186 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_get_clock_rate()
189 return -ENXIO; in snd_motu_protocol_v1_get_clock_rate()
194 __be32 reg; in set_clock_rate_828() local
195 u32 data; in set_clock_rate_828() local
198 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in set_clock_rate_828()
201 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in set_clock_rate_828()
203 data &= ~CLK_828_STATUS_FLAG_RATE_48000; in set_clock_rate_828()
205 data |= CLK_828_STATUS_FLAG_RATE_48000; in set_clock_rate_828()
207 reg = cpu_to_be32(data); in set_clock_rate_828()
208 return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in set_clock_rate_828()
214 __be32 reg; in set_clock_rate_896() local
215 u32 data; in set_clock_rate_896() local
218 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in set_clock_rate_896()
221 data = be32_to_cpu(reg); in set_clock_rate_896()
237 return -EINVAL; in set_clock_rate_896()
240 data &= ~CLK_896_STATUS_MASK_RATE; in set_clock_rate_896()
241 data |= flag; in set_clock_rate_896()
243 reg = cpu_to_be32(data); in set_clock_rate_896()
244 return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in set_clock_rate_896()
249 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_set_clock_rate()
251 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_set_clock_rate()
254 return -ENXIO; in snd_motu_protocol_v1_set_clock_rate()
259 __be32 reg; in get_clock_source_828() local
260 u32 data; in get_clock_source_828() local
263 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in get_clock_source_828()
266 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in get_clock_source_828()
268 switch (data & CLK_828_STATUS_MASK_SRC) { in get_clock_source_828()
277 if (data & CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF) in get_clock_source_828()
290 return -ENXIO; in get_clock_source_828()
298 __be32 reg; in get_clock_source_896() local
299 u32 data; in get_clock_source_896() local
302 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in get_clock_source_896()
305 data = be32_to_cpu(reg); in get_clock_source_896()
307 switch (data & CLK_896_STATUS_MASK_SRC) { in get_clock_source_896()
327 return -ENXIO; in get_clock_source_896()
335 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_get_clock_source()
337 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_get_clock_source()
340 return -ENXIO; in snd_motu_protocol_v1_get_clock_source()
345 __be32 reg; in switch_fetching_mode_828() local
346 u32 data; in switch_fetching_mode_828() local
349 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in switch_fetching_mode_828()
352 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in switch_fetching_mode_828()
354 data &= ~(CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT); in switch_fetching_mode_828()
360 data |= CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT; in switch_fetching_mode_828()
363 reg = cpu_to_be32(data); in switch_fetching_mode_828()
364 return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in switch_fetching_mode_828()
369 __be32 reg; in switch_fetching_mode_896() local
370 u32 data; in switch_fetching_mode_896() local
373 err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in switch_fetching_mode_896()
376 data = be32_to_cpu(reg); in switch_fetching_mode_896()
378 data &= ~CLK_896_STATUS_FLAG_FETCH_ENABLE; in switch_fetching_mode_896()
380 data |= CLK_896_STATUS_FLAG_FETCH_ENABLE | CLK_896_STATUS_FLAG_OUTPUT_ON; in switch_fetching_mode_896()
382 reg = cpu_to_be32(data); in switch_fetching_mode_896()
383 return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, ®, sizeof(reg)); in switch_fetching_mode_896()
388 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_switch_fetching_mode()
390 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_switch_fetching_mode()
393 return -ENXIO; in snd_motu_protocol_v1_switch_fetching_mode()
398 __be32 reg; in detect_packet_formats_828() local
399 u32 data; in detect_packet_formats_828() local
402 motu->tx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_828()
403 motu->tx_packet_formats.msg_chunks = 2; in detect_packet_formats_828()
405 motu->rx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_828()
406 motu->rx_packet_formats.msg_chunks = 0; in detect_packet_formats_828()
408 err = snd_motu_transaction_read(motu, CLK_828_STATUS_OFFSET, ®, sizeof(reg)); in detect_packet_formats_828()
411 data = be32_to_cpu(reg) & CLK_828_STATUS_MASK; in detect_packet_formats_828()
414 if (!(data & CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF)) in detect_packet_formats_828()
415 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_828()
417 if (!(data & CLK_828_STATUS_FLAG_OPT_OUT_IFACE_IS_SPDIF)) in detect_packet_formats_828()
418 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_828()
426 motu->tx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_896()
427 motu->rx_packet_formats.pcm_byte_offset = 4; in detect_packet_formats_896()
429 // No message chunk in data block. in detect_packet_formats_896()
430 motu->tx_packet_formats.msg_chunks = 0; in detect_packet_formats_896()
431 motu->rx_packet_formats.msg_chunks = 0; in detect_packet_formats_896()
435 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_896()
436 motu->tx_packet_formats.pcm_chunks[1] += 8; in detect_packet_formats_896()
438 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_896()
439 motu->rx_packet_formats.pcm_chunks[1] += 8; in detect_packet_formats_896()
446 memcpy(motu->tx_packet_formats.pcm_chunks, motu->spec->tx_fixed_pcm_chunks, in snd_motu_protocol_v1_cache_packet_formats()
447 sizeof(motu->tx_packet_formats.pcm_chunks)); in snd_motu_protocol_v1_cache_packet_formats()
448 memcpy(motu->rx_packet_formats.pcm_chunks, motu->spec->rx_fixed_pcm_chunks, in snd_motu_protocol_v1_cache_packet_formats()
449 sizeof(motu->rx_packet_formats.pcm_chunks)); in snd_motu_protocol_v1_cache_packet_formats()
451 if (motu->spec == &snd_motu_spec_828) in snd_motu_protocol_v1_cache_packet_formats()
453 else if (motu->spec == &snd_motu_spec_896) in snd_motu_protocol_v1_cache_packet_formats()