Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tascam-stream.c - a part of driver for TASCAM FireWire series
16 static int get_clock(struct snd_tscm *tscm, u32 *data) in get_clock() argument
19 __be32 reg; in get_clock() local
23 err = snd_fw_transaction(tscm->unit, TCODE_READ_QUADLET_REQUEST, in get_clock()
25 ®, sizeof(reg), 0); in get_clock()
29 *data = be32_to_cpu(reg); in get_clock()
30 if (*data & CLOCK_STATUS_MASK) in get_clock()
39 return -EAGAIN; in get_clock()
47 u32 data; in set_clock() local
48 __be32 reg; in set_clock() local
51 err = get_clock(tscm, &data); in set_clock()
54 data &= CLOCK_CONFIG_MASK; in set_clock()
57 data &= 0x000000ff; in set_clock()
60 data |= 0x00000100; in set_clock()
63 data |= 0x00008000; in set_clock()
65 data |= 0x00000200; in set_clock()
68 data |= 0x00008000; in set_clock()
70 return -EAGAIN; in set_clock()
75 data &= 0x0000ff00; in set_clock()
76 data |= clock + 1; in set_clock()
79 reg = cpu_to_be32(data); in set_clock()
81 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in set_clock()
83 ®, sizeof(reg), 0); in set_clock()
87 if (data & 0x00008000) in set_clock()
88 reg = cpu_to_be32(0x0000001a); in set_clock()
90 reg = cpu_to_be32(0x0000000d); in set_clock()
92 return snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in set_clock()
94 ®, sizeof(reg), 0); in set_clock()
99 u32 data; in snd_tscm_stream_get_rate() local
102 err = get_clock(tscm, &data); in snd_tscm_stream_get_rate()
106 data = (data & 0xff000000) >> 24; in snd_tscm_stream_get_rate()
109 if ((data & 0x0f) == 0x01) in snd_tscm_stream_get_rate()
111 else if ((data & 0x0f) == 0x02) in snd_tscm_stream_get_rate()
114 return -EAGAIN; in snd_tscm_stream_get_rate()
117 if ((data & 0xf0) == 0x80) in snd_tscm_stream_get_rate()
119 else if ((data & 0xf0) != 0x00) in snd_tscm_stream_get_rate()
120 return -EAGAIN; in snd_tscm_stream_get_rate()
127 u32 data; in snd_tscm_stream_get_clock() local
130 err = get_clock(tscm, &data); in snd_tscm_stream_get_clock()
134 *clock = ((data & 0x00ff0000) >> 16) - 1; in snd_tscm_stream_get_clock()
136 return -EIO; in snd_tscm_stream_get_clock()
143 __be32 reg; in enable_data_channels() local
144 u32 data; in enable_data_channels() local
148 data = 0; in enable_data_channels()
149 for (i = 0; i < tscm->spec->pcm_capture_analog_channels; ++i) in enable_data_channels()
150 data |= BIT(i); in enable_data_channels()
151 if (tscm->spec->has_adat) in enable_data_channels()
152 data |= 0x0000ff00; in enable_data_channels()
153 if (tscm->spec->has_spdif) in enable_data_channels()
154 data |= 0x00030000; in enable_data_channels()
156 reg = cpu_to_be32(data); in enable_data_channels()
157 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in enable_data_channels()
159 ®, sizeof(reg), 0); in enable_data_channels()
163 data = 0; in enable_data_channels()
164 for (i = 0; i < tscm->spec->pcm_playback_analog_channels; ++i) in enable_data_channels()
165 data |= BIT(i); in enable_data_channels()
166 if (tscm->spec->has_adat) in enable_data_channels()
167 data |= 0x0000ff00; in enable_data_channels()
168 if (tscm->spec->has_spdif) in enable_data_channels()
169 data |= 0x00030000; in enable_data_channels()
171 reg = cpu_to_be32(data); in enable_data_channels()
172 return snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in enable_data_channels()
174 ®, sizeof(reg), 0); in enable_data_channels()
179 __be32 reg; in set_stream_formats() local
183 reg = cpu_to_be32(0x00200000); in set_stream_formats()
184 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in set_stream_formats()
186 ®, sizeof(reg), 0); in set_stream_formats()
195 __be32 reg; in finish_session() local
197 reg = 0; in finish_session()
198 snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
200 ®, sizeof(reg), 0); in finish_session()
202 reg = 0; in finish_session()
203 snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
205 ®, sizeof(reg), 0); in finish_session()
208 reg = cpu_to_be32(0x00000000); in finish_session()
209 snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
211 ®, sizeof(reg), 0); in finish_session()
212 reg = cpu_to_be32(0x00000000); in finish_session()
213 snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
215 ®, sizeof(reg), 0); in finish_session()
216 reg = cpu_to_be32(0x00000000); in finish_session()
217 snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in finish_session()
219 ®, sizeof(reg), 0); in finish_session()
224 __be32 reg; in begin_session() local
228 reg = cpu_to_be32(tscm->tx_resources.channel); in begin_session()
229 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
231 ®, sizeof(reg), 0); in begin_session()
236 reg = cpu_to_be32(0x00000002); in begin_session()
237 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
239 ®, sizeof(reg), 0); in begin_session()
244 reg = cpu_to_be32(tscm->rx_resources.channel); in begin_session()
245 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
247 ®, sizeof(reg), 0); in begin_session()
251 reg = cpu_to_be32(0x00000001); in begin_session()
252 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
254 ®, sizeof(reg), 0); in begin_session()
258 reg = cpu_to_be32(0x00000001); in begin_session()
259 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
261 ®, sizeof(reg), 0); in begin_session()
266 reg = cpu_to_be32(0x00002000); in begin_session()
267 err = snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST, in begin_session()
269 ®, sizeof(reg), 0); in begin_session()
274 reg = cpu_to_be32(0x00000001); in begin_session()
275 return snd_fw_transaction(tscm->unit, in begin_session()
278 ®, sizeof(reg), 0); in begin_session()
287 if (stream == &tscm->tx_stream) in keep_resources()
288 resources = &tscm->tx_resources; in keep_resources()
290 resources = &tscm->rx_resources; in keep_resources()
298 fw_parent_device(tscm->unit)->max_speed); in keep_resources()
308 if (s == &tscm->tx_stream) { in init_stream()
309 resources = &tscm->tx_resources; in init_stream()
311 pcm_channels = tscm->spec->pcm_capture_analog_channels; in init_stream()
313 resources = &tscm->rx_resources; in init_stream()
315 pcm_channels = tscm->spec->pcm_playback_analog_channels; in init_stream()
318 if (tscm->spec->has_adat) in init_stream()
320 if (tscm->spec->has_spdif) in init_stream()
323 err = fw_iso_resources_init(resources, tscm->unit); in init_stream()
327 err = amdtp_tscm_init(s, tscm->unit, dir, pcm_channels); in init_stream()
338 if (s == &tscm->tx_stream) in destroy_stream()
339 fw_iso_resources_destroy(&tscm->tx_resources); in destroy_stream()
341 fw_iso_resources_destroy(&tscm->rx_resources); in destroy_stream()
348 err = init_stream(tscm, &tscm->tx_stream); in snd_tscm_stream_init_duplex()
352 err = init_stream(tscm, &tscm->rx_stream); in snd_tscm_stream_init_duplex()
354 destroy_stream(tscm, &tscm->tx_stream); in snd_tscm_stream_init_duplex()
358 err = amdtp_domain_init(&tscm->domain); in snd_tscm_stream_init_duplex()
360 destroy_stream(tscm, &tscm->tx_stream); in snd_tscm_stream_init_duplex()
361 destroy_stream(tscm, &tscm->rx_stream); in snd_tscm_stream_init_duplex()
370 amdtp_domain_stop(&tscm->domain); in snd_tscm_stream_update_duplex()
372 amdtp_stream_pcm_abort(&tscm->tx_stream); in snd_tscm_stream_update_duplex()
373 amdtp_stream_pcm_abort(&tscm->rx_stream); in snd_tscm_stream_update_duplex()
380 amdtp_domain_destroy(&tscm->domain); in snd_tscm_stream_destroy_duplex()
382 destroy_stream(tscm, &tscm->rx_stream); in snd_tscm_stream_destroy_duplex()
383 destroy_stream(tscm, &tscm->tx_stream); in snd_tscm_stream_destroy_duplex()
397 if (tscm->substreams_counter == 0 || rate != curr_rate) { in snd_tscm_stream_reserve_duplex()
398 amdtp_domain_stop(&tscm->domain); in snd_tscm_stream_reserve_duplex()
402 fw_iso_resources_free(&tscm->tx_resources); in snd_tscm_stream_reserve_duplex()
403 fw_iso_resources_free(&tscm->rx_resources); in snd_tscm_stream_reserve_duplex()
409 err = keep_resources(tscm, rate, &tscm->tx_stream); in snd_tscm_stream_reserve_duplex()
413 err = keep_resources(tscm, rate, &tscm->rx_stream); in snd_tscm_stream_reserve_duplex()
415 fw_iso_resources_free(&tscm->tx_resources); in snd_tscm_stream_reserve_duplex()
419 err = amdtp_domain_set_events_per_period(&tscm->domain, in snd_tscm_stream_reserve_duplex()
422 fw_iso_resources_free(&tscm->tx_resources); in snd_tscm_stream_reserve_duplex()
423 fw_iso_resources_free(&tscm->rx_resources); in snd_tscm_stream_reserve_duplex()
427 tscm->need_long_tx_init_skip = (rate != curr_rate); in snd_tscm_stream_reserve_duplex()
435 unsigned int generation = tscm->rx_resources.generation; in snd_tscm_stream_start_duplex()
438 if (tscm->substreams_counter == 0) in snd_tscm_stream_start_duplex()
441 if (amdtp_streaming_error(&tscm->rx_stream) || in snd_tscm_stream_start_duplex()
442 amdtp_streaming_error(&tscm->tx_stream)) { in snd_tscm_stream_start_duplex()
443 amdtp_domain_stop(&tscm->domain); in snd_tscm_stream_start_duplex()
447 if (generation != fw_parent_device(tscm->unit)->card->generation) { in snd_tscm_stream_start_duplex()
448 err = fw_iso_resources_update(&tscm->tx_resources); in snd_tscm_stream_start_duplex()
452 err = fw_iso_resources_update(&tscm->rx_resources); in snd_tscm_stream_start_duplex()
457 if (!amdtp_stream_running(&tscm->rx_stream)) { in snd_tscm_stream_start_duplex()
458 int spd = fw_parent_device(tscm->unit)->max_speed; in snd_tscm_stream_start_duplex()
469 err = amdtp_domain_add_stream(&tscm->domain, &tscm->rx_stream, in snd_tscm_stream_start_duplex()
470 tscm->rx_resources.channel, spd); in snd_tscm_stream_start_duplex()
474 err = amdtp_domain_add_stream(&tscm->domain, &tscm->tx_stream, in snd_tscm_stream_start_duplex()
475 tscm->tx_resources.channel, spd); in snd_tscm_stream_start_duplex()
479 if (tscm->need_long_tx_init_skip) in snd_tscm_stream_start_duplex()
489 // of CIP header in received packets. The sequence of the number of data blocks per in snd_tscm_stream_start_duplex()
491 err = amdtp_domain_start(&tscm->domain, tx_init_skip_cycles, true, true); in snd_tscm_stream_start_duplex()
495 if (!amdtp_domain_wait_ready(&tscm->domain, READY_TIMEOUT_MS)) { in snd_tscm_stream_start_duplex()
496 err = -ETIMEDOUT; in snd_tscm_stream_start_duplex()
503 amdtp_domain_stop(&tscm->domain); in snd_tscm_stream_start_duplex()
511 if (tscm->substreams_counter == 0) { in snd_tscm_stream_stop_duplex()
512 amdtp_domain_stop(&tscm->domain); in snd_tscm_stream_stop_duplex()
515 fw_iso_resources_free(&tscm->tx_resources); in snd_tscm_stream_stop_duplex()
516 fw_iso_resources_free(&tscm->rx_resources); in snd_tscm_stream_stop_duplex()
518 tscm->need_long_tx_init_skip = false; in snd_tscm_stream_stop_duplex()
524 tscm->dev_lock_changed = true; in snd_tscm_stream_lock_changed()
525 wake_up(&tscm->hwdep_wait); in snd_tscm_stream_lock_changed()
532 spin_lock_irq(&tscm->lock); in snd_tscm_stream_lock_try()
535 if (tscm->dev_lock_count < 0) { in snd_tscm_stream_lock_try()
536 err = -EBUSY; in snd_tscm_stream_lock_try()
541 if (tscm->dev_lock_count++ == 0) in snd_tscm_stream_lock_try()
545 spin_unlock_irq(&tscm->lock); in snd_tscm_stream_lock_try()
551 spin_lock_irq(&tscm->lock); in snd_tscm_stream_lock_release()
553 if (WARN_ON(tscm->dev_lock_count <= 0)) in snd_tscm_stream_lock_release()
555 if (--tscm->dev_lock_count == 0) in snd_tscm_stream_lock_release()
558 spin_unlock_irq(&tscm->lock); in snd_tscm_stream_lock_release()