2 * tascam.h - a part of driver for TASCAM FireWire series
4 * Copyright (c) 2015 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
9 #ifndef SOUND_TASCAM_H_INCLUDED
10 #define SOUND_TASCAM_H_INCLUDED
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>
21 #include <sound/core.h>
22 #include <sound/initval.h>
23 #include <sound/info.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/firewire.h>
27 #include <sound/hwdep.h>
28 #include <sound/rawmidi.h>
31 #include "../amdtp-stream.h"
32 #include "../iso-resources.h"
34 struct snd_tscm_spec {
35 const char *const name;
38 unsigned int pcm_capture_analog_channels;
39 unsigned int pcm_playback_analog_channels;
40 unsigned int midi_capture_ports;
41 unsigned int midi_playback_ports;
45 #define TSCM_MIDI_IN_PORT_MAX 4
46 #define TSCM_MIDI_OUT_PORT_MAX 4
49 struct snd_card *card;
55 const struct snd_tscm_spec *spec;
57 struct fw_iso_resources tx_resources;
58 struct fw_iso_resources rx_resources;
59 struct amdtp_stream tx_stream;
60 struct amdtp_stream rx_stream;
61 unsigned int substreams_counter;
64 bool dev_lock_changed;
65 wait_queue_head_t hwdep_wait;
67 /* For MIDI message incoming transactions. */
68 struct fw_address_handler async_handler;
69 struct snd_rawmidi_substream *tx_midi_substreams[TSCM_MIDI_IN_PORT_MAX];
72 #define TSCM_ADDR_BASE 0xffff00000000ull
74 #define TSCM_OFFSET_FIRMWARE_REGISTER 0x0000
75 #define TSCM_OFFSET_FIRMWARE_FPGA 0x0004
76 #define TSCM_OFFSET_FIRMWARE_ARM 0x0008
77 #define TSCM_OFFSET_FIRMWARE_HW 0x000c
79 #define TSCM_OFFSET_ISOC_TX_CH 0x0200
80 #define TSCM_OFFSET_UNKNOWN 0x0204
81 #define TSCM_OFFSET_START_STREAMING 0x0208
82 #define TSCM_OFFSET_ISOC_RX_CH 0x020c
83 #define TSCM_OFFSET_ISOC_RX_ON 0x0210 /* Little conviction. */
84 #define TSCM_OFFSET_TX_PCM_CHANNELS 0x0214
85 #define TSCM_OFFSET_RX_PCM_CHANNELS 0x0218
86 #define TSCM_OFFSET_MULTIPLEX_MODE 0x021c
87 #define TSCM_OFFSET_ISOC_TX_ON 0x0220
89 #define TSCM_OFFSET_CLOCK_STATUS 0x0228
90 #define TSCM_OFFSET_SET_OPTION 0x022c
92 #define TSCM_OFFSET_MIDI_TX_ON 0x0300
93 #define TSCM_OFFSET_MIDI_TX_ADDR_HI 0x0304
94 #define TSCM_OFFSET_MIDI_TX_ADDR_LO 0x0308
96 #define TSCM_OFFSET_MIDI_RX_QUAD 0x4000
99 SND_TSCM_CLOCK_INTERNAL = 0,
100 SND_TSCM_CLOCK_WORD = 1,
101 SND_TSCM_CLOCK_SPDIF = 2,
102 SND_TSCM_CLOCK_ADAT = 3,
105 int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
106 enum amdtp_stream_direction dir, unsigned int pcm_channels);
107 int amdtp_tscm_set_parameters(struct amdtp_stream *s, unsigned int rate);
108 int amdtp_tscm_add_pcm_hw_constraints(struct amdtp_stream *s,
109 struct snd_pcm_runtime *runtime);
110 void amdtp_tscm_set_pcm_format(struct amdtp_stream *s, snd_pcm_format_t format);
112 int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate);
113 int snd_tscm_stream_get_clock(struct snd_tscm *tscm,
114 enum snd_tscm_clock *clock);
115 int snd_tscm_stream_init_duplex(struct snd_tscm *tscm);
116 void snd_tscm_stream_update_duplex(struct snd_tscm *tscm);
117 void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm);
118 int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate);
119 void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm);
121 void snd_tscm_stream_lock_changed(struct snd_tscm *tscm);
122 int snd_tscm_stream_lock_try(struct snd_tscm *tscm);
123 void snd_tscm_stream_lock_release(struct snd_tscm *tscm);
125 int snd_tscm_transaction_register(struct snd_tscm *tscm);
126 int snd_tscm_transaction_reregister(struct snd_tscm *tscm);
127 void snd_tscm_transaction_unregister(struct snd_tscm *tscm);
129 void snd_tscm_proc_init(struct snd_tscm *tscm);
131 int snd_tscm_create_pcm_devices(struct snd_tscm *tscm);
133 int snd_tscm_create_hwdep_device(struct snd_tscm *tscm);