^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * motu.h - a part of driver for MOTU FireWire series
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef SOUND_FIREWIRE_MOTU_H_INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define SOUND_FIREWIRE_MOTU_H_INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/firewire.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/firewire-constants.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mod_devicetable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <sound/control.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <sound/info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <sound/rawmidi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <sound/firewire.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <sound/hwdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "../lib.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "../amdtp-stream.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "../iso-resources.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct snd_motu_packet_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned char midi_flag_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned char midi_byte_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned char pcm_byte_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned char msg_chunks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned char pcm_chunks[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct snd_motu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct fw_unit *unit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct delayed_work dwork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* Model dependent information. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) const struct snd_motu_spec *spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* For packet streaming */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct snd_motu_packet_format tx_packet_formats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct snd_motu_packet_format rx_packet_formats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct amdtp_stream tx_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct amdtp_stream rx_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct fw_iso_resources tx_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct fw_iso_resources rx_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned int substreams_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* For notification. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct fw_address_handler async_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u32 msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* For uapi */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int dev_lock_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) bool dev_lock_changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) wait_queue_head_t hwdep_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct amdtp_domain domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) enum snd_motu_spec_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) SND_MOTU_SPEC_RX_MIDI_2ND_Q = 0x0001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) SND_MOTU_SPEC_RX_MIDI_3RD_Q = 0x0002,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) SND_MOTU_SPEC_TX_MIDI_2ND_Q = 0x0004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) SND_MOTU_SPEC_TX_MIDI_3RD_Q = 0x0008,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define SND_MOTU_CLOCK_RATE_COUNT 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) extern const unsigned int snd_motu_clock_rates[SND_MOTU_CLOCK_RATE_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum snd_motu_clock_source {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) SND_MOTU_CLOCK_SOURCE_INTERNAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_A,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) SND_MOTU_CLOCK_SOURCE_SPH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) SND_MOTU_CLOCK_SOURCE_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) enum snd_motu_protocol_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) SND_MOTU_PROTOCOL_V2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) SND_MOTU_PROTOCOL_V3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct snd_motu_spec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) const char *const name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) enum snd_motu_protocol_version protocol_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) enum snd_motu_spec_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned char tx_fixed_pcm_chunks[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned char rx_fixed_pcm_chunks[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) extern const struct snd_motu_spec snd_motu_spec_828mk2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) extern const struct snd_motu_spec snd_motu_spec_traveler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern const struct snd_motu_spec snd_motu_spec_ultralite;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) extern const struct snd_motu_spec snd_motu_spec_8pre;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) extern const struct snd_motu_spec snd_motu_spec_828mk3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) extern const struct snd_motu_spec snd_motu_spec_ultralite_mk3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) extern const struct snd_motu_spec snd_motu_spec_audio_express;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) extern const struct snd_motu_spec snd_motu_spec_4pre;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) enum amdtp_stream_direction dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) const struct snd_motu_spec *spec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int amdtp_motu_set_parameters(struct amdtp_stream *s, unsigned int rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned int midi_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct snd_motu_packet_format *formats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int amdtp_motu_add_pcm_hw_constraints(struct amdtp_stream *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct snd_pcm_runtime *runtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void amdtp_motu_midi_trigger(struct amdtp_stream *s, unsigned int port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct snd_rawmidi_substream *midi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int snd_motu_transaction_read(struct snd_motu *motu, u32 offset, __be32 *reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int snd_motu_transaction_write(struct snd_motu *motu, u32 offset, __be32 *reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int snd_motu_transaction_register(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int snd_motu_transaction_reregister(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void snd_motu_transaction_unregister(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int snd_motu_stream_init_duplex(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void snd_motu_stream_destroy_duplex(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int snd_motu_stream_cache_packet_formats(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned int frames_per_period,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) unsigned int frames_per_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int snd_motu_stream_start_duplex(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void snd_motu_stream_stop_duplex(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int snd_motu_stream_lock_try(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) void snd_motu_stream_lock_release(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) void snd_motu_proc_init(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int snd_motu_create_pcm_devices(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int snd_motu_create_midi_devices(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int snd_motu_create_hwdep_device(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int snd_motu_protocol_v2_get_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) unsigned int *rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int snd_motu_protocol_v2_set_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned int rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int snd_motu_protocol_v2_get_clock_source(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) enum snd_motu_clock_source *src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) bool enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) int snd_motu_protocol_v3_get_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) unsigned int *rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int snd_motu_protocol_v3_set_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) unsigned int rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int snd_motu_protocol_v3_get_clock_source(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) enum snd_motu_clock_source *src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int snd_motu_protocol_v3_switch_fetching_mode(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) bool enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int snd_motu_protocol_v3_cache_packet_formats(struct snd_motu *motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static inline int snd_motu_protocol_get_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) unsigned int *rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return snd_motu_protocol_v2_get_clock_rate(motu, rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) else if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return snd_motu_protocol_v3_get_clock_rate(motu, rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static inline int snd_motu_protocol_set_clock_rate(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned int rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return snd_motu_protocol_v2_set_clock_rate(motu, rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) else if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return snd_motu_protocol_v3_set_clock_rate(motu, rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline int snd_motu_protocol_get_clock_source(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) enum snd_motu_clock_source *source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return snd_motu_protocol_v2_get_clock_source(motu, source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) else if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) return snd_motu_protocol_v3_get_clock_source(motu, source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static inline int snd_motu_protocol_switch_fetching_mode(struct snd_motu *motu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) bool enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return snd_motu_protocol_v2_switch_fetching_mode(motu, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) else if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return snd_motu_protocol_v3_switch_fetching_mode(motu, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline int snd_motu_protocol_cache_packet_formats(struct snd_motu *motu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return snd_motu_protocol_v2_cache_packet_formats(motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) else if (motu->spec->protocol_version == SND_MOTU_PROTOCOL_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return snd_motu_protocol_v3_cache_packet_formats(motu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #endif