Merge remote-tracking branch 'regulator/for-next'
[deliverable/linux.git] / sound / firewire / fireworks / fireworks.h
CommitLineData
b5b04336
TS
1/*
2 * fireworks.h - a part of driver for Fireworks based devices
3 *
4 * Copyright (c) 2009-2010 Clemens Ladisch
5 * Copyright (c) 2013-2014 Takashi Sakamoto
6 *
7 * Licensed under the terms of the GNU General Public License, version 2.
8 */
9#ifndef SOUND_FIREWORKS_H_INCLUDED
10#define SOUND_FIREWORKS_H_INCLUDED
11
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>
20
21#include <sound/core.h>
22#include <sound/initval.h>
bde8a8f2 23#include <sound/pcm.h>
6a22683e 24#include <sound/info.h>
a63d3ff1 25#include <sound/rawmidi.h>
aa02bb6e 26#include <sound/pcm_params.h>
594ddced
TS
27#include <sound/firewire.h>
28#include <sound/hwdep.h>
bde8a8f2 29
315fd41f
TS
30#include "../packets-buffer.h"
31#include "../iso-resources.h"
5955815e 32#include "../amdtp-am824.h"
bde8a8f2
TS
33#include "../cmp.h"
34#include "../lib.h"
35
315fd41f
TS
36#define SND_EFW_MAX_MIDI_OUT_PORTS 2
37#define SND_EFW_MAX_MIDI_IN_PORTS 2
38
bde8a8f2
TS
39#define SND_EFW_MULTIPLIER_MODES 3
40#define HWINFO_NAME_SIZE_BYTES 32
41#define HWINFO_MAX_CAPS_GROUPS 8
42
43/*
44 * This should be greater than maximum bytes for EFW response content.
45 * Currently response against command for isochronous channel mapping is
46 * confirmed to be the maximum one. But for flexibility, use maximum data
47 * payload for asynchronous primary packets at S100 (Cable base rate) in
48 * IEEE Std 1394-1995.
49 */
50#define SND_EFW_RESPONSE_MAXIMUM_BYTES 0x200U
51
555e8a8f
TS
52extern unsigned int snd_efw_resp_buf_size;
53extern bool snd_efw_resp_buf_debug;
54
bde8a8f2
TS
55struct snd_efw_phys_grp {
56 u8 type; /* see enum snd_efw_grp_type */
57 u8 count;
58} __packed;
b5b04336
TS
59
60struct snd_efw {
61 struct snd_card *card;
62 struct fw_unit *unit;
63 int card_index;
64
65 struct mutex mutex;
66 spinlock_t lock;
bde8a8f2 67
7d3c1d59
TS
68 bool registered;
69 struct delayed_work dwork;
70
bde8a8f2
TS
71 /* for transaction */
72 u32 seqnum;
73 bool resp_addr_changable;
315fd41f 74
69702239
TS
75 /* for quirks */
76 bool is_af9;
18f5ed36 77 bool is_fireworks3;
d9cd0065 78 u32 firmware_version;
69702239 79
315fd41f
TS
80 unsigned int midi_in_ports;
81 unsigned int midi_out_ports;
82
83 unsigned int supported_sampling_rate;
84 unsigned int pcm_capture_channels[SND_EFW_MULTIPLIER_MODES];
85 unsigned int pcm_playback_channels[SND_EFW_MULTIPLIER_MODES];
86
315fd41f
TS
87 struct amdtp_stream tx_stream;
88 struct amdtp_stream rx_stream;
89 struct cmp_connection out_conn;
90 struct cmp_connection in_conn;
4d2c50a0
TS
91 unsigned int capture_substreams;
92 unsigned int playback_substreams;
6a22683e
TS
93
94 /* hardware metering parameters */
95 unsigned int phys_out;
96 unsigned int phys_in;
97 unsigned int phys_out_grp_count;
98 unsigned int phys_in_grp_count;
99 struct snd_efw_phys_grp phys_out_grps[HWINFO_MAX_CAPS_GROUPS];
100 struct snd_efw_phys_grp phys_in_grps[HWINFO_MAX_CAPS_GROUPS];
594ddced
TS
101
102 /* for uapi */
103 int dev_lock_count;
104 bool dev_lock_changed;
105 wait_queue_head_t hwdep_wait;
bde8a8f2 106
555e8a8f
TS
107 /* response queue */
108 u8 *resp_buf;
109 u8 *pull_ptr;
110 u8 *push_ptr;
bde8a8f2 111};
555e8a8f
TS
112
113int snd_efw_transaction_cmd(struct fw_unit *unit,
114 const void *cmd, unsigned int size);
bde8a8f2
TS
115int snd_efw_transaction_run(struct fw_unit *unit,
116 const void *cmd, unsigned int cmd_size,
117 void *resp, unsigned int resp_size);
118int snd_efw_transaction_register(void);
119void snd_efw_transaction_unregister(void);
120void snd_efw_transaction_bus_reset(struct fw_unit *unit);
555e8a8f
TS
121void snd_efw_transaction_add_instance(struct snd_efw *efw);
122void snd_efw_transaction_remove_instance(struct snd_efw *efw);
bde8a8f2
TS
123
124struct snd_efw_hwinfo {
125 u32 flags;
126 u32 guid_hi;
127 u32 guid_lo;
128 u32 type;
129 u32 version;
130 char vendor_name[HWINFO_NAME_SIZE_BYTES];
131 char model_name[HWINFO_NAME_SIZE_BYTES];
132 u32 supported_clocks;
133 u32 amdtp_rx_pcm_channels;
134 u32 amdtp_tx_pcm_channels;
135 u32 phys_out;
136 u32 phys_in;
137 u32 phys_out_grp_count;
138 struct snd_efw_phys_grp phys_out_grps[HWINFO_MAX_CAPS_GROUPS];
139 u32 phys_in_grp_count;
140 struct snd_efw_phys_grp phys_in_grps[HWINFO_MAX_CAPS_GROUPS];
141 u32 midi_out_ports;
142 u32 midi_in_ports;
143 u32 max_sample_rate;
144 u32 min_sample_rate;
145 u32 dsp_version;
146 u32 arm_version;
147 u32 mixer_playback_channels;
148 u32 mixer_capture_channels;
149 u32 fpga_version;
150 u32 amdtp_rx_pcm_channels_2x;
151 u32 amdtp_tx_pcm_channels_2x;
152 u32 amdtp_rx_pcm_channels_4x;
153 u32 amdtp_tx_pcm_channels_4x;
154 u32 reserved[16];
155} __packed;
156enum snd_efw_grp_type {
157 SND_EFW_CH_TYPE_ANALOG = 0,
158 SND_EFW_CH_TYPE_SPDIF = 1,
159 SND_EFW_CH_TYPE_ADAT = 2,
160 SND_EFW_CH_TYPE_SPDIF_OR_ADAT = 3,
161 SND_EFW_CH_TYPE_ANALOG_MIRRORING = 4,
162 SND_EFW_CH_TYPE_HEADPHONES = 5,
163 SND_EFW_CH_TYPE_I2S = 6,
164 SND_EFW_CH_TYPE_GUITAR = 7,
165 SND_EFW_CH_TYPE_PIEZO_GUITAR = 8,
166 SND_EFW_CH_TYPE_GUITAR_STRING = 9,
bde8a8f2
TS
167 SND_EFW_CH_TYPE_DUMMY
168};
169struct snd_efw_phys_meters {
170 u32 status; /* guitar state/midi signal/clock input detect */
171 u32 reserved0;
172 u32 reserved1;
173 u32 reserved2;
174 u32 reserved3;
175 u32 out_meters;
176 u32 in_meters;
177 u32 reserved4;
178 u32 reserved5;
179 u32 values[0];
180} __packed;
181enum snd_efw_clock_source {
182 SND_EFW_CLOCK_SOURCE_INTERNAL = 0,
183 SND_EFW_CLOCK_SOURCE_SYTMATCH = 1,
184 SND_EFW_CLOCK_SOURCE_WORDCLOCK = 2,
185 SND_EFW_CLOCK_SOURCE_SPDIF = 3,
186 SND_EFW_CLOCK_SOURCE_ADAT_1 = 4,
187 SND_EFW_CLOCK_SOURCE_ADAT_2 = 5,
188 SND_EFW_CLOCK_SOURCE_CONTINUOUS = 6 /* internal variable clock */
189};
190enum snd_efw_transport_mode {
191 SND_EFW_TRANSPORT_MODE_WINDOWS = 0,
192 SND_EFW_TRANSPORT_MODE_IEC61883 = 1,
b5b04336 193};
bde8a8f2
TS
194int snd_efw_command_set_resp_addr(struct snd_efw *efw,
195 u16 addr_high, u32 addr_low);
93219d06
TS
196int snd_efw_command_set_tx_mode(struct snd_efw *efw,
197 enum snd_efw_transport_mode mode);
bde8a8f2
TS
198int snd_efw_command_get_hwinfo(struct snd_efw *efw,
199 struct snd_efw_hwinfo *hwinfo);
200int snd_efw_command_get_phys_meters(struct snd_efw *efw,
201 struct snd_efw_phys_meters *meters,
202 unsigned int len);
203int snd_efw_command_get_clock_source(struct snd_efw *efw,
204 enum snd_efw_clock_source *source);
205int snd_efw_command_get_sampling_rate(struct snd_efw *efw, unsigned int *rate);
206int snd_efw_command_set_sampling_rate(struct snd_efw *efw, unsigned int rate);
b5b04336 207
315fd41f 208int snd_efw_stream_init_duplex(struct snd_efw *efw);
4a286d55 209int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate);
315fd41f
TS
210void snd_efw_stream_stop_duplex(struct snd_efw *efw);
211void snd_efw_stream_update_duplex(struct snd_efw *efw);
212void snd_efw_stream_destroy_duplex(struct snd_efw *efw);
594ddced
TS
213void snd_efw_stream_lock_changed(struct snd_efw *efw);
214int snd_efw_stream_lock_try(struct snd_efw *efw);
215void snd_efw_stream_lock_release(struct snd_efw *efw);
315fd41f 216
6a22683e
TS
217void snd_efw_proc_init(struct snd_efw *efw);
218
a63d3ff1
TS
219int snd_efw_create_midi_devices(struct snd_efw *efw);
220
aa02bb6e
TS
221int snd_efw_create_pcm_devices(struct snd_efw *efw);
222int snd_efw_get_multiplier_mode(unsigned int sampling_rate, unsigned int *mode);
223
594ddced
TS
224int snd_efw_create_hwdep_device(struct snd_efw *efw);
225
b5b04336
TS
226#define SND_EFW_DEV_ENTRY(vendor, model) \
227{ \
228 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
229 IEEE1394_MATCH_MODEL_ID, \
230 .vendor_id = vendor,\
231 .model_id = model \
232}
233
234#endif
This page took 0.121979 seconds and 5 git commands to generate.