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>
28 #define SND_EFW_MULTIPLIER_MODES 3
29 #define HWINFO_NAME_SIZE_BYTES 32
30 #define HWINFO_MAX_CAPS_GROUPS 8
33 * This should be greater than maximum bytes for EFW response content.
34 * Currently response against command for isochronous channel mapping is
35 * confirmed to be the maximum one. But for flexibility, use maximum data
36 * payload for asynchronous primary packets at S100 (Cable base rate) in
39 #define SND_EFW_RESPONSE_MAXIMUM_BYTES 0x200U
41 struct snd_efw_phys_grp {
42 u8 type; /* see enum snd_efw_grp_type */
47 struct snd_card *card;
56 bool resp_addr_changable;
59 struct snd_efw_transaction {
68 int snd_efw_transaction_run(struct fw_unit *unit,
69 const void *cmd, unsigned int cmd_size,
70 void *resp, unsigned int resp_size);
71 int snd_efw_transaction_register(void);
72 void snd_efw_transaction_unregister(void);
73 void snd_efw_transaction_bus_reset(struct fw_unit *unit);
75 struct snd_efw_hwinfo {
81 char vendor_name[HWINFO_NAME_SIZE_BYTES];
82 char model_name[HWINFO_NAME_SIZE_BYTES];
84 u32 amdtp_rx_pcm_channels;
85 u32 amdtp_tx_pcm_channels;
88 u32 phys_out_grp_count;
89 struct snd_efw_phys_grp phys_out_grps[HWINFO_MAX_CAPS_GROUPS];
90 u32 phys_in_grp_count;
91 struct snd_efw_phys_grp phys_in_grps[HWINFO_MAX_CAPS_GROUPS];
98 u32 mixer_playback_channels;
99 u32 mixer_capture_channels;
101 u32 amdtp_rx_pcm_channels_2x;
102 u32 amdtp_tx_pcm_channels_2x;
103 u32 amdtp_rx_pcm_channels_4x;
104 u32 amdtp_tx_pcm_channels_4x;
107 enum snd_efw_grp_type {
108 SND_EFW_CH_TYPE_ANALOG = 0,
109 SND_EFW_CH_TYPE_SPDIF = 1,
110 SND_EFW_CH_TYPE_ADAT = 2,
111 SND_EFW_CH_TYPE_SPDIF_OR_ADAT = 3,
112 SND_EFW_CH_TYPE_ANALOG_MIRRORING = 4,
113 SND_EFW_CH_TYPE_HEADPHONES = 5,
114 SND_EFW_CH_TYPE_I2S = 6,
115 SND_EFW_CH_TYPE_GUITAR = 7,
116 SND_EFW_CH_TYPE_PIEZO_GUITAR = 8,
117 SND_EFW_CH_TYPE_GUITAR_STRING = 9,
118 SND_EFW_CH_TYPE_VIRTUAL = 0x10000,
119 SND_EFW_CH_TYPE_DUMMY
121 struct snd_efw_phys_meters {
122 u32 status; /* guitar state/midi signal/clock input detect */
133 enum snd_efw_clock_source {
134 SND_EFW_CLOCK_SOURCE_INTERNAL = 0,
135 SND_EFW_CLOCK_SOURCE_SYTMATCH = 1,
136 SND_EFW_CLOCK_SOURCE_WORDCLOCK = 2,
137 SND_EFW_CLOCK_SOURCE_SPDIF = 3,
138 SND_EFW_CLOCK_SOURCE_ADAT_1 = 4,
139 SND_EFW_CLOCK_SOURCE_ADAT_2 = 5,
140 SND_EFW_CLOCK_SOURCE_CONTINUOUS = 6 /* internal variable clock */
142 enum snd_efw_transport_mode {
143 SND_EFW_TRANSPORT_MODE_WINDOWS = 0,
144 SND_EFW_TRANSPORT_MODE_IEC61883 = 1,
146 int snd_efw_command_set_resp_addr(struct snd_efw *efw,
147 u16 addr_high, u32 addr_low);
148 int snd_efw_command_set_tx_mode(struct snd_efw *efw, unsigned int mode);
149 int snd_efw_command_get_hwinfo(struct snd_efw *efw,
150 struct snd_efw_hwinfo *hwinfo);
151 int snd_efw_command_get_phys_meters(struct snd_efw *efw,
152 struct snd_efw_phys_meters *meters,
154 int snd_efw_command_get_clock_source(struct snd_efw *efw,
155 enum snd_efw_clock_source *source);
156 int snd_efw_command_get_sampling_rate(struct snd_efw *efw, unsigned int *rate);
157 int snd_efw_command_set_sampling_rate(struct snd_efw *efw, unsigned int rate);
159 #define SND_EFW_DEV_ENTRY(vendor, model) \
161 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
162 IEEE1394_MATCH_MODEL_ID, \
163 .vendor_id = vendor,\