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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * motu-protocol-v2.c - a part of driver for MOTU FireWire series
5 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
34 static int get_clock_rate(u32 data, unsigned int *rate) in get_clock_rate() argument
36 unsigned int index = (data & V2_CLOCK_RATE_MASK) >> V2_CLOCK_RATE_SHIFT; in get_clock_rate()
38 return -EIO; in get_clock_rate()
48 __be32 reg; in snd_motu_protocol_v2_get_clock_rate() local
51 err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, &reg, in snd_motu_protocol_v2_get_clock_rate()
52 sizeof(reg)); in snd_motu_protocol_v2_get_clock_rate()
56 return get_clock_rate(be32_to_cpu(reg), rate); in snd_motu_protocol_v2_get_clock_rate()
62 __be32 reg; in snd_motu_protocol_v2_set_clock_rate() local
63 u32 data; in snd_motu_protocol_v2_set_clock_rate() local
72 return -EINVAL; in snd_motu_protocol_v2_set_clock_rate()
74 err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, &reg, in snd_motu_protocol_v2_set_clock_rate()
75 sizeof(reg)); in snd_motu_protocol_v2_set_clock_rate()
78 data = be32_to_cpu(reg); in snd_motu_protocol_v2_set_clock_rate()
80 data &= ~V2_CLOCK_RATE_MASK; in snd_motu_protocol_v2_set_clock_rate()
81 data |= i << V2_CLOCK_RATE_SHIFT; in snd_motu_protocol_v2_set_clock_rate()
83 reg = cpu_to_be32(data); in snd_motu_protocol_v2_set_clock_rate()
84 return snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET, &reg, in snd_motu_protocol_v2_set_clock_rate()
85 sizeof(reg)); in snd_motu_protocol_v2_set_clock_rate()
88 static int get_clock_source(struct snd_motu *motu, u32 data, in get_clock_source() argument
91 switch (data & V2_CLOCK_SRC_MASK) { in get_clock_source()
100 bool support_iec60958_on_opt = (motu->spec == &snd_motu_spec_828mk2 || in get_clock_source()
101 motu->spec == &snd_motu_spec_traveler); in get_clock_source()
103 if (motu->spec == &snd_motu_spec_896hd) { in get_clock_source()
108 __be32 reg; in get_clock_source() local
111 int err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET, &reg, in get_clock_source()
112 sizeof(reg)); in get_clock_source()
116 if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == in get_clock_source()
148 __be32 reg; in snd_motu_protocol_v2_get_clock_source() local
151 err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, &reg, in snd_motu_protocol_v2_get_clock_source()
152 sizeof(reg)); in snd_motu_protocol_v2_get_clock_source()
156 return get_clock_source(motu, be32_to_cpu(reg), src); in snd_motu_protocol_v2_get_clock_source()
160 static int switch_fetching_mode_cyclone(struct snd_motu *motu, u32 *data, in switch_fetching_mode_cyclone() argument
163 *data |= V2_CLOCK_MODEL_SPECIFIC; in switch_fetching_mode_cyclone()
169 static int switch_fetching_mode_spartan(struct snd_motu *motu, u32 *data, in switch_fetching_mode_spartan() argument
176 err = get_clock_source(motu, *data, &src); in switch_fetching_mode_spartan()
180 err = get_clock_rate(*data, &rate); in switch_fetching_mode_spartan()
185 *data |= V2_CLOCK_MODEL_SPECIFIC; in switch_fetching_mode_spartan()
193 if (motu->spec == &snd_motu_spec_828mk2) { in snd_motu_protocol_v2_switch_fetching_mode()
196 } else if (motu->spec == &snd_motu_spec_896hd) { in snd_motu_protocol_v2_switch_fetching_mode()
200 __be32 reg; in snd_motu_protocol_v2_switch_fetching_mode() local
201 u32 data; in snd_motu_protocol_v2_switch_fetching_mode() local
205 &reg, sizeof(reg)); in snd_motu_protocol_v2_switch_fetching_mode()
208 data = be32_to_cpu(reg); in snd_motu_protocol_v2_switch_fetching_mode()
210 data &= ~(V2_CLOCK_FETCH_ENABLE | V2_CLOCK_MODEL_SPECIFIC); in snd_motu_protocol_v2_switch_fetching_mode()
212 data |= V2_CLOCK_FETCH_ENABLE; in snd_motu_protocol_v2_switch_fetching_mode()
214 if (motu->spec == &snd_motu_spec_traveler) in snd_motu_protocol_v2_switch_fetching_mode()
215 err = switch_fetching_mode_cyclone(motu, &data, enable); in snd_motu_protocol_v2_switch_fetching_mode()
217 err = switch_fetching_mode_spartan(motu, &data, enable); in snd_motu_protocol_v2_switch_fetching_mode()
221 reg = cpu_to_be32(data); in snd_motu_protocol_v2_switch_fetching_mode()
223 &reg, sizeof(reg)); in snd_motu_protocol_v2_switch_fetching_mode()
229 bool has_two_opt_ifaces = (motu->spec == &snd_motu_spec_8pre); in snd_motu_protocol_v2_cache_packet_formats()
230 __be32 reg; in snd_motu_protocol_v2_cache_packet_formats() local
231 u32 data; in snd_motu_protocol_v2_cache_packet_formats() local
234 motu->tx_packet_formats.pcm_byte_offset = 10; in snd_motu_protocol_v2_cache_packet_formats()
235 motu->rx_packet_formats.pcm_byte_offset = 10; in snd_motu_protocol_v2_cache_packet_formats()
237 motu->tx_packet_formats.msg_chunks = 2; in snd_motu_protocol_v2_cache_packet_formats()
238 motu->rx_packet_formats.msg_chunks = 2; in snd_motu_protocol_v2_cache_packet_formats()
240 err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET, &reg, in snd_motu_protocol_v2_cache_packet_formats()
241 sizeof(reg)); in snd_motu_protocol_v2_cache_packet_formats()
244 data = be32_to_cpu(reg); in snd_motu_protocol_v2_cache_packet_formats()
246 memcpy(motu->tx_packet_formats.pcm_chunks, in snd_motu_protocol_v2_cache_packet_formats()
247 motu->spec->tx_fixed_pcm_chunks, in snd_motu_protocol_v2_cache_packet_formats()
248 sizeof(motu->tx_packet_formats.pcm_chunks)); in snd_motu_protocol_v2_cache_packet_formats()
249 memcpy(motu->rx_packet_formats.pcm_chunks, in snd_motu_protocol_v2_cache_packet_formats()
250 motu->spec->rx_fixed_pcm_chunks, in snd_motu_protocol_v2_cache_packet_formats()
251 sizeof(motu->rx_packet_formats.pcm_chunks)); in snd_motu_protocol_v2_cache_packet_formats()
253 if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == V2_OPT_IFACE_MODE_ADAT) { in snd_motu_protocol_v2_cache_packet_formats()
254 motu->tx_packet_formats.pcm_chunks[0] += 8; in snd_motu_protocol_v2_cache_packet_formats()
257 motu->tx_packet_formats.pcm_chunks[1] += 4; in snd_motu_protocol_v2_cache_packet_formats()
259 motu->tx_packet_formats.pcm_chunks[1] += 8; in snd_motu_protocol_v2_cache_packet_formats()
262 if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) == V2_OPT_IFACE_MODE_ADAT) { in snd_motu_protocol_v2_cache_packet_formats()
263 motu->rx_packet_formats.pcm_chunks[0] += 8; in snd_motu_protocol_v2_cache_packet_formats()
266 motu->rx_packet_formats.pcm_chunks[1] += 4; in snd_motu_protocol_v2_cache_packet_formats()
268 motu->rx_packet_formats.pcm_chunks[1] += 8; in snd_motu_protocol_v2_cache_packet_formats()
318 // Two dummy chunks always in the end of data block.