Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
3 * motu-protocol-v3.c - a part of driver for MOTU FireWire series
5 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
40 __be32 reg; in snd_motu_protocol_v3_get_clock_rate() local
41 u32 data; in snd_motu_protocol_v3_get_clock_rate() local
44 err = snd_motu_transaction_read(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_get_clock_rate()
45 sizeof(reg)); in snd_motu_protocol_v3_get_clock_rate()
48 data = be32_to_cpu(reg); in snd_motu_protocol_v3_get_clock_rate()
50 data = (data & V3_CLOCK_RATE_MASK) >> V3_CLOCK_RATE_SHIFT; in snd_motu_protocol_v3_get_clock_rate()
51 if (data >= ARRAY_SIZE(snd_motu_clock_rates)) in snd_motu_protocol_v3_get_clock_rate()
52 return -EIO; in snd_motu_protocol_v3_get_clock_rate()
54 *rate = snd_motu_clock_rates[data]; in snd_motu_protocol_v3_get_clock_rate()
62 __be32 reg; in snd_motu_protocol_v3_set_clock_rate() local
63 u32 data; in snd_motu_protocol_v3_set_clock_rate() local
72 return -EINVAL; in snd_motu_protocol_v3_set_clock_rate()
74 err = snd_motu_transaction_read(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_set_clock_rate()
75 sizeof(reg)); in snd_motu_protocol_v3_set_clock_rate()
78 data = be32_to_cpu(reg); in snd_motu_protocol_v3_set_clock_rate()
80 data &= ~(V3_CLOCK_RATE_MASK | V3_FETCH_PCM_FRAMES); in snd_motu_protocol_v3_set_clock_rate()
81 data |= i << V3_CLOCK_RATE_SHIFT; in snd_motu_protocol_v3_set_clock_rate()
83 need_to_wait = data != be32_to_cpu(reg); in snd_motu_protocol_v3_set_clock_rate()
85 reg = cpu_to_be32(data); in snd_motu_protocol_v3_set_clock_rate()
86 err = snd_motu_transaction_write(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_set_clock_rate()
87 sizeof(reg)); in snd_motu_protocol_v3_set_clock_rate()
94 motu->msg = 0; in snd_motu_protocol_v3_set_clock_rate()
95 result = wait_event_interruptible_timeout(motu->hwdep_wait, in snd_motu_protocol_v3_set_clock_rate()
96 motu->msg & V3_MSG_FLAG_CLK_CHANGED, in snd_motu_protocol_v3_set_clock_rate()
101 return -ETIMEDOUT; in snd_motu_protocol_v3_set_clock_rate()
110 __be32 reg; in snd_motu_protocol_v3_get_clock_source() local
111 u32 data; in snd_motu_protocol_v3_get_clock_source() local
114 err = snd_motu_transaction_read(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_get_clock_source()
115 sizeof(reg)); in snd_motu_protocol_v3_get_clock_source()
118 data = be32_to_cpu(reg) & V3_CLOCK_SOURCE_MASK; in snd_motu_protocol_v3_get_clock_source()
120 switch (data) { in snd_motu_protocol_v3_get_clock_source()
139 __be32 reg; in snd_motu_protocol_v3_get_clock_source() local
143 V3_OPT_IFACE_MODE_OFFSET, ®, sizeof(reg)); in snd_motu_protocol_v3_get_clock_source()
146 options = be32_to_cpu(reg); in snd_motu_protocol_v3_get_clock_source()
148 if (data == V3_CLOCK_SRC_OPT_IFACE_A) { in snd_motu_protocol_v3_get_clock_source()
172 __be32 reg; in snd_motu_protocol_v3_switch_fetching_mode() local
173 u32 data; in snd_motu_protocol_v3_switch_fetching_mode() local
176 err = snd_motu_transaction_read(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_switch_fetching_mode()
177 sizeof(reg)); in snd_motu_protocol_v3_switch_fetching_mode()
180 data = be32_to_cpu(reg); in snd_motu_protocol_v3_switch_fetching_mode()
183 data |= V3_FETCH_PCM_FRAMES; in snd_motu_protocol_v3_switch_fetching_mode()
185 data &= ~V3_FETCH_PCM_FRAMES; in snd_motu_protocol_v3_switch_fetching_mode()
187 reg = cpu_to_be32(data); in snd_motu_protocol_v3_switch_fetching_mode()
188 return snd_motu_transaction_write(motu, V3_CLOCK_STATUS_OFFSET, ®, in snd_motu_protocol_v3_switch_fetching_mode()
189 sizeof(reg)); in snd_motu_protocol_v3_switch_fetching_mode()
192 static int detect_packet_formats_with_opt_ifaces(struct snd_motu *motu, u32 data) in detect_packet_formats_with_opt_ifaces() argument
194 if (data & V3_ENABLE_OPT_IN_IFACE_A) { in detect_packet_formats_with_opt_ifaces()
195 if (data & V3_NO_ADAT_OPT_IN_IFACE_A) { in detect_packet_formats_with_opt_ifaces()
196 motu->tx_packet_formats.pcm_chunks[0] += 4; in detect_packet_formats_with_opt_ifaces()
197 motu->tx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
199 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_with_opt_ifaces()
200 motu->tx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
204 if (data & V3_ENABLE_OPT_IN_IFACE_B) { in detect_packet_formats_with_opt_ifaces()
205 if (data & V3_NO_ADAT_OPT_IN_IFACE_B) { in detect_packet_formats_with_opt_ifaces()
206 motu->tx_packet_formats.pcm_chunks[0] += 4; in detect_packet_formats_with_opt_ifaces()
207 motu->tx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
209 motu->tx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_with_opt_ifaces()
210 motu->tx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
214 if (data & V3_ENABLE_OPT_OUT_IFACE_A) { in detect_packet_formats_with_opt_ifaces()
215 if (data & V3_NO_ADAT_OPT_OUT_IFACE_A) { in detect_packet_formats_with_opt_ifaces()
216 motu->rx_packet_formats.pcm_chunks[0] += 4; in detect_packet_formats_with_opt_ifaces()
217 motu->rx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
219 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_with_opt_ifaces()
220 motu->rx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
224 if (data & V3_ENABLE_OPT_OUT_IFACE_B) { in detect_packet_formats_with_opt_ifaces()
225 if (data & V3_NO_ADAT_OPT_OUT_IFACE_B) { in detect_packet_formats_with_opt_ifaces()
226 motu->rx_packet_formats.pcm_chunks[0] += 4; in detect_packet_formats_with_opt_ifaces()
227 motu->rx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
229 motu->rx_packet_formats.pcm_chunks[0] += 8; in detect_packet_formats_with_opt_ifaces()
230 motu->rx_packet_formats.pcm_chunks[1] += 4; in detect_packet_formats_with_opt_ifaces()
239 __be32 reg; in snd_motu_protocol_v3_cache_packet_formats() local
240 u32 data; in snd_motu_protocol_v3_cache_packet_formats() local
243 motu->tx_packet_formats.pcm_byte_offset = 10; in snd_motu_protocol_v3_cache_packet_formats()
244 motu->rx_packet_formats.pcm_byte_offset = 10; in snd_motu_protocol_v3_cache_packet_formats()
246 motu->tx_packet_formats.msg_chunks = 2; in snd_motu_protocol_v3_cache_packet_formats()
247 motu->rx_packet_formats.msg_chunks = 2; in snd_motu_protocol_v3_cache_packet_formats()
249 err = snd_motu_transaction_read(motu, V3_OPT_IFACE_MODE_OFFSET, ®, in snd_motu_protocol_v3_cache_packet_formats()
250 sizeof(reg)); in snd_motu_protocol_v3_cache_packet_formats()
253 data = be32_to_cpu(reg); in snd_motu_protocol_v3_cache_packet_formats()
255 memcpy(motu->tx_packet_formats.pcm_chunks, in snd_motu_protocol_v3_cache_packet_formats()
256 motu->spec->tx_fixed_pcm_chunks, in snd_motu_protocol_v3_cache_packet_formats()
257 sizeof(motu->tx_packet_formats.pcm_chunks)); in snd_motu_protocol_v3_cache_packet_formats()
258 memcpy(motu->rx_packet_formats.pcm_chunks, in snd_motu_protocol_v3_cache_packet_formats()
259 motu->spec->rx_fixed_pcm_chunks, in snd_motu_protocol_v3_cache_packet_formats()
260 sizeof(motu->rx_packet_formats.pcm_chunks)); in snd_motu_protocol_v3_cache_packet_formats()
262 if (motu->spec == &snd_motu_spec_828mk3_fw || in snd_motu_protocol_v3_cache_packet_formats()
263 motu->spec == &snd_motu_spec_828mk3_hybrid || in snd_motu_protocol_v3_cache_packet_formats()
264 motu->spec == &snd_motu_spec_896mk3 || in snd_motu_protocol_v3_cache_packet_formats()
265 motu->spec == &snd_motu_spec_traveler_mk3 || in snd_motu_protocol_v3_cache_packet_formats()
266 motu->spec == &snd_motu_spec_track16) in snd_motu_protocol_v3_cache_packet_formats()
267 return detect_packet_formats_with_opt_ifaces(motu, data); in snd_motu_protocol_v3_cache_packet_formats()