2 * fireworks.h - a part of driver for Fireworks based devices
4 * Copyright (c) 2009-2010 Clemens Ladisch
5 * Copyright (c) 2013-2014 Takashi Sakamoto
7 * Licensed under the terms of the GNU General Public License, version 2.
9 #ifndef SOUND_FIREWORKS_H_INCLUDED
10 #define SOUND_FIREWORKS_H_INCLUDED
12 #include <linux/compat.h>
13 #include <linux/device.h>
14 #include <linux/firewire.h>
15 #include <linux/firewire-constants.h>
16 #include <linux/module.h>
17 #include <linux/mod_devicetable.h>
18 #include <linux/delay.h>
19 #include <linux/slab.h>
21 #include <sound/core.h>
22 #include <sound/initval.h>
23 #include <sound/pcm.h>
25 #include "../packets-buffer.h"
26 #include "../iso-resources.h"
31 #define SND_EFW_MAX_MIDI_OUT_PORTS 2
32 #define SND_EFW_MAX_MIDI_IN_PORTS 2
34 #define SND_EFW_MULTIPLIER_MODES 3
35 #define HWINFO_NAME_SIZE_BYTES 32
36 #define HWINFO_MAX_CAPS_GROUPS 8
39 * This should be greater than maximum bytes for EFW response content.
40 * Currently response against command for isochronous channel mapping is
41 * confirmed to be the maximum one. But for flexibility, use maximum data
42 * payload for asynchronous primary packets at S100 (Cable base rate) in
45 #define SND_EFW_RESPONSE_MAXIMUM_BYTES 0x200U
47 struct snd_efw_phys_grp {
48 u8 type; /* see enum snd_efw_grp_type */
53 struct snd_card *card;
62 bool resp_addr_changable;
67 unsigned int midi_in_ports;
68 unsigned int midi_out_ports;
70 unsigned int supported_sampling_rate;
71 unsigned int pcm_capture_channels[SND_EFW_MULTIPLIER_MODES];
72 unsigned int pcm_playback_channels[SND_EFW_MULTIPLIER_MODES];
74 struct amdtp_stream *master;
75 struct amdtp_stream tx_stream;
76 struct amdtp_stream rx_stream;
77 struct cmp_connection out_conn;
78 struct cmp_connection in_conn;
79 atomic_t capture_substreams;
80 atomic_t playback_substreams;
83 struct snd_efw_transaction {
92 int snd_efw_transaction_run(struct fw_unit *unit,
93 const void *cmd, unsigned int cmd_size,
94 void *resp, unsigned int resp_size);
95 int snd_efw_transaction_register(void);
96 void snd_efw_transaction_unregister(void);
97 void snd_efw_transaction_bus_reset(struct fw_unit *unit);
99 struct snd_efw_hwinfo {
105 char vendor_name[HWINFO_NAME_SIZE_BYTES];
106 char model_name[HWINFO_NAME_SIZE_BYTES];
107 u32 supported_clocks;
108 u32 amdtp_rx_pcm_channels;
109 u32 amdtp_tx_pcm_channels;
112 u32 phys_out_grp_count;
113 struct snd_efw_phys_grp phys_out_grps[HWINFO_MAX_CAPS_GROUPS];
114 u32 phys_in_grp_count;
115 struct snd_efw_phys_grp phys_in_grps[HWINFO_MAX_CAPS_GROUPS];
122 u32 mixer_playback_channels;
123 u32 mixer_capture_channels;
125 u32 amdtp_rx_pcm_channels_2x;
126 u32 amdtp_tx_pcm_channels_2x;
127 u32 amdtp_rx_pcm_channels_4x;
128 u32 amdtp_tx_pcm_channels_4x;
131 enum snd_efw_grp_type {
132 SND_EFW_CH_TYPE_ANALOG = 0,
133 SND_EFW_CH_TYPE_SPDIF = 1,
134 SND_EFW_CH_TYPE_ADAT = 2,
135 SND_EFW_CH_TYPE_SPDIF_OR_ADAT = 3,
136 SND_EFW_CH_TYPE_ANALOG_MIRRORING = 4,
137 SND_EFW_CH_TYPE_HEADPHONES = 5,
138 SND_EFW_CH_TYPE_I2S = 6,
139 SND_EFW_CH_TYPE_GUITAR = 7,
140 SND_EFW_CH_TYPE_PIEZO_GUITAR = 8,
141 SND_EFW_CH_TYPE_GUITAR_STRING = 9,
142 SND_EFW_CH_TYPE_VIRTUAL = 0x10000,
143 SND_EFW_CH_TYPE_DUMMY
145 struct snd_efw_phys_meters {
146 u32 status; /* guitar state/midi signal/clock input detect */
157 enum snd_efw_clock_source {
158 SND_EFW_CLOCK_SOURCE_INTERNAL = 0,
159 SND_EFW_CLOCK_SOURCE_SYTMATCH = 1,
160 SND_EFW_CLOCK_SOURCE_WORDCLOCK = 2,
161 SND_EFW_CLOCK_SOURCE_SPDIF = 3,
162 SND_EFW_CLOCK_SOURCE_ADAT_1 = 4,
163 SND_EFW_CLOCK_SOURCE_ADAT_2 = 5,
164 SND_EFW_CLOCK_SOURCE_CONTINUOUS = 6 /* internal variable clock */
166 enum snd_efw_transport_mode {
167 SND_EFW_TRANSPORT_MODE_WINDOWS = 0,
168 SND_EFW_TRANSPORT_MODE_IEC61883 = 1,
170 int snd_efw_command_set_resp_addr(struct snd_efw *efw,
171 u16 addr_high, u32 addr_low);
172 int snd_efw_command_set_tx_mode(struct snd_efw *efw, unsigned int mode);
173 int snd_efw_command_get_hwinfo(struct snd_efw *efw,
174 struct snd_efw_hwinfo *hwinfo);
175 int snd_efw_command_get_phys_meters(struct snd_efw *efw,
176 struct snd_efw_phys_meters *meters,
178 int snd_efw_command_get_clock_source(struct snd_efw *efw,
179 enum snd_efw_clock_source *source);
180 int snd_efw_command_get_sampling_rate(struct snd_efw *efw, unsigned int *rate);
181 int snd_efw_command_set_sampling_rate(struct snd_efw *efw, unsigned int rate);
183 int snd_efw_stream_init_duplex(struct snd_efw *efw);
184 int snd_efw_stream_start_duplex(struct snd_efw *efw, int sampling_rate);
185 void snd_efw_stream_stop_duplex(struct snd_efw *efw);
186 void snd_efw_stream_update_duplex(struct snd_efw *efw);
187 void snd_efw_stream_destroy_duplex(struct snd_efw *efw);
189 #define SND_EFW_DEV_ENTRY(vendor, model) \
191 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
192 IEEE1394_MATCH_MODEL_ID, \
193 .vendor_id = vendor,\