~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/firewire/motu/motu.h

Version: ~ [ linux-5.13-rc1 ] ~ [ linux-5.12.2 ] ~ [ linux-5.11.19 ] ~ [ linux-5.10.35 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.117 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.190 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.232 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.268 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.268 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * motu.h - a part of driver for MOTU FireWire series
  3  *
  4  * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
  5  *
  6  * Licensed under the terms of the GNU General Public License, version 2.
  7  */
  8 
  9 #ifndef SOUND_FIREWIRE_MOTU_H_INCLUDED
 10 #define SOUND_FIREWIRE_MOTU_H_INCLUDED
 11 
 12 #include <linux/device.h>
 13 #include <linux/firewire.h>
 14 #include <linux/firewire-constants.h>
 15 #include <linux/module.h>
 16 #include <linux/mod_devicetable.h>
 17 #include <linux/mutex.h>
 18 #include <linux/slab.h>
 19 #include <linux/compat.h>
 20 #include <linux/sched/signal.h>
 21 
 22 #include <sound/control.h>
 23 #include <sound/core.h>
 24 #include <sound/pcm.h>
 25 #include <sound/info.h>
 26 #include <sound/rawmidi.h>
 27 #include <sound/firewire.h>
 28 #include <sound/hwdep.h>
 29 
 30 #include "../lib.h"
 31 #include "../amdtp-stream.h"
 32 #include "../iso-resources.h"
 33 
 34 struct snd_motu_packet_format {
 35         unsigned char midi_flag_offset;
 36         unsigned char midi_byte_offset;
 37         unsigned char pcm_byte_offset;
 38 
 39         unsigned char msg_chunks;
 40         unsigned char fixed_part_pcm_chunks[3];
 41         unsigned char differed_part_pcm_chunks[3];
 42 };
 43 
 44 struct snd_motu {
 45         struct snd_card *card;
 46         struct fw_unit *unit;
 47         struct mutex mutex;
 48         spinlock_t lock;
 49 
 50         bool registered;
 51         struct delayed_work dwork;
 52 
 53         /* Model dependent information. */
 54         const struct snd_motu_spec *spec;
 55 
 56         /* For packet streaming */
 57         struct snd_motu_packet_format tx_packet_formats;
 58         struct snd_motu_packet_format rx_packet_formats;
 59         struct amdtp_stream tx_stream;
 60         struct amdtp_stream rx_stream;
 61         struct fw_iso_resources tx_resources;
 62         struct fw_iso_resources rx_resources;
 63         unsigned int capture_substreams;
 64         unsigned int playback_substreams;
 65 
 66         /* For notification. */
 67         struct fw_address_handler async_handler;
 68         u32 msg;
 69 
 70         /* For uapi */
 71         int dev_lock_count;
 72         bool dev_lock_changed;
 73         wait_queue_head_t hwdep_wait;
 74 };
 75 
 76 enum snd_motu_spec_flags {
 77         SND_MOTU_SPEC_SUPPORT_CLOCK_X2  = 0x0001,
 78         SND_MOTU_SPEC_SUPPORT_CLOCK_X4  = 0x0002,
 79         SND_MOTU_SPEC_TX_MICINST_CHUNK  = 0x0004,
 80         SND_MOTU_SPEC_TX_RETURN_CHUNK   = 0x0008,
 81         SND_MOTU_SPEC_TX_REVERB_CHUNK   = 0x0010,
 82         SND_MOTU_SPEC_TX_AESEBU_CHUNK   = 0x0020,
 83         SND_MOTU_SPEC_HAS_OPT_IFACE_A   = 0x0040,
 84         SND_MOTU_SPEC_HAS_OPT_IFACE_B   = 0x0080,
 85         SND_MOTU_SPEC_HAS_MIDI          = 0x0100,
 86 };
 87 
 88 #define SND_MOTU_CLOCK_RATE_COUNT       6
 89 extern const unsigned int snd_motu_clock_rates[SND_MOTU_CLOCK_RATE_COUNT];
 90 
 91 enum snd_motu_clock_source {
 92         SND_MOTU_CLOCK_SOURCE_INTERNAL,
 93         SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB,
 94         SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT,
 95         SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_A,
 96         SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_B,
 97         SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT,
 98         SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A,
 99         SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B,
100         SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX,
101         SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR,
102         SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC,
103         SND_MOTU_CLOCK_SOURCE_UNKNOWN,
104 };
105 
106 struct snd_motu_protocol {
107         int (*get_clock_rate)(struct snd_motu *motu, unsigned int *rate);
108         int (*set_clock_rate)(struct snd_motu *motu, unsigned int rate);
109         int (*get_clock_source)(struct snd_motu *motu,
110                                 enum snd_motu_clock_source *source);
111         int (*switch_fetching_mode)(struct snd_motu *motu, bool enable);
112         int (*cache_packet_formats)(struct snd_motu *motu);
113 };
114 
115 struct snd_motu_spec {
116         const char *const name;
117         enum snd_motu_spec_flags flags;
118 
119         unsigned char analog_in_ports;
120         unsigned char analog_out_ports;
121 
122         const struct snd_motu_protocol *const protocol;
123 };
124 
125 extern const struct snd_motu_protocol snd_motu_protocol_v2;
126 extern const struct snd_motu_protocol snd_motu_protocol_v3;
127 
128 int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
129                     enum amdtp_stream_direction dir,
130                     const struct snd_motu_protocol *const protocol);
131 int amdtp_motu_set_parameters(struct amdtp_stream *s, unsigned int rate,
132                               unsigned int midi_ports,
133                               struct snd_motu_packet_format *formats);
134 int amdtp_motu_add_pcm_hw_constraints(struct amdtp_stream *s,
135                                       struct snd_pcm_runtime *runtime);
136 void amdtp_motu_midi_trigger(struct amdtp_stream *s, unsigned int port,
137                              struct snd_rawmidi_substream *midi);
138 
139 int snd_motu_transaction_read(struct snd_motu *motu, u32 offset, __be32 *reg,
140                               size_t size);
141 int snd_motu_transaction_write(struct snd_motu *motu, u32 offset, __be32 *reg,
142                                size_t size);
143 int snd_motu_transaction_register(struct snd_motu *motu);
144 int snd_motu_transaction_reregister(struct snd_motu *motu);
145 void snd_motu_transaction_unregister(struct snd_motu *motu);
146 
147 int snd_motu_stream_init_duplex(struct snd_motu *motu);
148 void snd_motu_stream_destroy_duplex(struct snd_motu *motu);
149 int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate);
150 void snd_motu_stream_stop_duplex(struct snd_motu *motu);
151 int snd_motu_stream_lock_try(struct snd_motu *motu);
152 void snd_motu_stream_lock_release(struct snd_motu *motu);
153 
154 void snd_motu_proc_init(struct snd_motu *motu);
155 
156 int snd_motu_create_pcm_devices(struct snd_motu *motu);
157 
158 int snd_motu_create_midi_devices(struct snd_motu *motu);
159 
160 int snd_motu_create_hwdep_device(struct snd_motu *motu);
161 #endif
162 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp