summaryrefslogtreecommitdiffstats
path: root/sound/firewire/bebob
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-04-25 09:45:25 -0400
committerTakashi Iwai <tiwai@suse.de>2014-05-26 08:32:03 -0400
commit9076c22ddd9d29a30426f0367dec2b40e12536de (patch)
tree8fd173e744c1080bdc13e0c9cdb486d4094fb2e4 /sound/firewire/bebob
parent25784ec2d0347b715e354d92151734afe1296f02 (diff)
ALSA: bebob: Add support for M-Audio usual Firewire series
This commit allows this driver to support some models which M-Audio produces with DM1000/DM1000E with usual firmware. They are: - Firewire 410 - Firewire AudioPhile - Firewire Solo - Ozonic - NRV10 - FirewireLightBridge According to a person who worked in BridgeCo, some models are produced with 'Pre-BeBoB'. This means that these products were released before BeBoB was officially produced, and later BeBoB specification was formed. So these models have some quirks. M-Audio usual firmware quirks: - Just after powering on, 'Firewire 410' waits to download firmware. This state is changed when receiving cue. Then bus reset is generated and the device is recognized as a different model with the uploaded firmware. - 'Firewire Audiophile' also waits to download firmware but its vendor id/model id is the same as the one after loading firmware. - The information of channel mapping for MIDI conformant data channel is invalid against BridgeCo specification. This commit adds some codes for these quirks but don't support to upload firmware. This commit also adds specific operations to get metering information. The metering information also includes status of clock synchronization if the model supports to switch source of clock. The specification of FirewireLightBridge is unknown. So in this time, normal operations are applied for this model. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob')
-rw-r--r--sound/firewire/bebob/Makefile2
-rw-r--r--sound/firewire/bebob/bebob.c45
-rw-r--r--sound/firewire/bebob/bebob.h5
-rw-r--r--sound/firewire/bebob/bebob_maudio.c180
-rw-r--r--sound/firewire/bebob/bebob_stream.c9
5 files changed, 238 insertions, 3 deletions
diff --git a/sound/firewire/bebob/Makefile b/sound/firewire/bebob/Makefile
index 656542077b12..6cf470c80d1f 100644
--- a/sound/firewire/bebob/Makefile
+++ b/sound/firewire/bebob/Makefile
@@ -1,4 +1,4 @@
1snd-bebob-objs := bebob_command.o bebob_stream.o bebob_proc.o bebob_midi.o \ 1snd-bebob-objs := bebob_command.o bebob_stream.o bebob_proc.o bebob_midi.o \
2 bebob_pcm.o bebob_hwdep.o bebob_terratec.o bebob_yamaha.o \ 2 bebob_pcm.o bebob_hwdep.o bebob_terratec.o bebob_yamaha.o \
3 bebob_focusrite.o bebob.o 3 bebob_focusrite.o bebob_maudio.o bebob.o
4obj-m += snd-bebob.o 4obj-m += snd-bebob.o
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
index 6d23e44e635b..9bf9149194df 100644
--- a/sound/firewire/bebob/bebob.c
+++ b/sound/firewire/bebob/bebob.c
@@ -55,8 +55,11 @@ static DECLARE_BITMAP(devices_used, SNDRV_CARDS);
55#define VEN_TERRATEC 0x00000aac 55#define VEN_TERRATEC 0x00000aac
56#define VEN_YAMAHA 0x0000a0de 56#define VEN_YAMAHA 0x0000a0de
57#define VEN_FOCUSRITE 0x0000130e 57#define VEN_FOCUSRITE 0x0000130e
58#define VEN_MAUDIO1 0x00000d6c
59#define VEN_MAUDIO2 0x000007f5
58 60
59#define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000 61#define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000
62#define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060
60 63
61static int 64static int
62name_device(struct snd_bebob *bebob, unsigned int vendor_id) 65name_device(struct snd_bebob *bebob, unsigned int vendor_id)
@@ -139,6 +142,17 @@ get_saffire_spec(struct fw_unit *unit)
139 return &saffire_spec; 142 return &saffire_spec;
140} 143}
141 144
145static bool
146check_audiophile_booted(struct fw_unit *unit)
147{
148 char name[24] = {0};
149
150 if (fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)) < 0)
151 return false;
152
153 return strncmp(name, "FW Audiophile Bootloader", 15) != 0;
154}
155
142static int 156static int
143bebob_probe(struct fw_unit *unit, 157bebob_probe(struct fw_unit *unit,
144 const struct ieee1394_device_id *entry) 158 const struct ieee1394_device_id *entry)
@@ -161,10 +175,16 @@ bebob_probe(struct fw_unit *unit,
161 } 175 }
162 176
163 if ((entry->vendor_id == VEN_FOCUSRITE) && 177 if ((entry->vendor_id == VEN_FOCUSRITE) &&
164 (entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH)) 178 (entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH)) {
165 spec = get_saffire_spec(unit); 179 spec = get_saffire_spec(unit);
166 else 180 } else if ((entry->vendor_id == VEN_MAUDIO1) &&
181 (entry->model_id == MODEL_MAUDIO_AUDIOPHILE_BOTH) &&
182 !check_audiophile_booted(unit)) {
183 err = 0;
184 goto end;
185 } else {
167 spec = (const struct snd_bebob_spec *)entry->driver_data; 186 spec = (const struct snd_bebob_spec *)entry->driver_data;
187 }
168 if (spec == NULL) { 188 if (spec == NULL) {
169 err = -ENOSYS; 189 err = -ENOSYS;
170 goto end; 190 goto end;
@@ -235,6 +255,10 @@ static void
235bebob_update(struct fw_unit *unit) 255bebob_update(struct fw_unit *unit)
236{ 256{
237 struct snd_bebob *bebob = dev_get_drvdata(&unit->device); 257 struct snd_bebob *bebob = dev_get_drvdata(&unit->device);
258
259 if (bebob == NULL)
260 return;
261
238 fcp_bus_reset(bebob->unit); 262 fcp_bus_reset(bebob->unit);
239 snd_bebob_stream_update_duplex(bebob); 263 snd_bebob_stream_update_duplex(bebob);
240} 264}
@@ -242,6 +266,10 @@ bebob_update(struct fw_unit *unit)
242static void bebob_remove(struct fw_unit *unit) 266static void bebob_remove(struct fw_unit *unit)
243{ 267{
244 struct snd_bebob *bebob = dev_get_drvdata(&unit->device); 268 struct snd_bebob *bebob = dev_get_drvdata(&unit->device);
269
270 if (bebob == NULL)
271 return;
272
245 snd_bebob_stream_destroy_duplex(bebob); 273 snd_bebob_stream_destroy_duplex(bebob);
246 snd_card_disconnect(bebob->card); 274 snd_card_disconnect(bebob->card);
247 snd_card_free_when_closed(bebob->card); 275 snd_card_free_when_closed(bebob->card);
@@ -334,6 +362,19 @@ static const struct ieee1394_device_id bebob_id_table[] = {
334 /* Focusrite, Saffire(no label and LE) */ 362 /* Focusrite, Saffire(no label and LE) */
335 SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, MODEL_FOCUSRITE_SAFFIRE_BOTH, 363 SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, MODEL_FOCUSRITE_SAFFIRE_BOTH,
336 &saffire_spec), 364 &saffire_spec),
365 /* M-Audio, Firewire 410 */
366 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO2, 0x00010046, &maudio_fw410_spec),
367 /* M-Audio, Firewire Audiophile */
368 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_AUDIOPHILE_BOTH,
369 &maudio_audiophile_spec),
370 /* M-Audio, Firewire Solo */
371 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010062, &maudio_solo_spec),
372 /* M-Audio, Ozonic */
373 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x0000000a, &maudio_ozonic_spec),
374 /* M-Audio NRV10 */
375 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010081, &maudio_nrv10_spec),
376 /* M-Audio, ProFireLightbridge */
377 SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x000100a1, &spec_normal),
337 /* IDs are unknown but able to be supported */ 378 /* IDs are unknown but able to be supported */
338 /* Apogee, Mini-ME Firewire */ 379 /* Apogee, Mini-ME Firewire */
339 /* Apogee, Mini-DAC Firewire */ 380 /* Apogee, Mini-DAC Firewire */
diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h
index 220b115785e2..a851639ead45 100644
--- a/sound/firewire/bebob/bebob.h
+++ b/sound/firewire/bebob/bebob.h
@@ -232,6 +232,11 @@ extern struct snd_bebob_spec saffirepro_26_spec;
232extern struct snd_bebob_spec saffirepro_10_spec; 232extern struct snd_bebob_spec saffirepro_10_spec;
233extern struct snd_bebob_spec saffire_le_spec; 233extern struct snd_bebob_spec saffire_le_spec;
234extern struct snd_bebob_spec saffire_spec; 234extern struct snd_bebob_spec saffire_spec;
235extern struct snd_bebob_spec maudio_fw410_spec;
236extern struct snd_bebob_spec maudio_audiophile_spec;
237extern struct snd_bebob_spec maudio_solo_spec;
238extern struct snd_bebob_spec maudio_ozonic_spec;
239extern struct snd_bebob_spec maudio_nrv10_spec;
235 240
236#define SND_BEBOB_DEV_ENTRY(vendor, model, data) \ 241#define SND_BEBOB_DEV_ENTRY(vendor, model, data) \
237{ \ 242{ \
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
new file mode 100644
index 000000000000..dededb35fbd7
--- /dev/null
+++ b/sound/firewire/bebob/bebob_maudio.c
@@ -0,0 +1,180 @@
1/*
2 * bebob_maudio.c - a part of driver for BeBoB based devices
3 *
4 * Copyright (c) 2013-2014 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include "./bebob.h"
10
11/*
12 * Just powering on, Firewire 410/Audiophile wait to
13 * download firmware blob. To enable these devices, drivers should upload
14 * firmware blob and send a command to initialize configuration to factory
15 * settings when completing uploading. Then these devices generate bus reset
16 * and are recognized as new devices with the firmware.
17 *
18 * For streaming, both of output and input streams are needed for Firewire 410
19 * and Ozonic. The single stream is OK for the other devices even if the clock
20 * source is not SYT-Match (I note no devices use SYT-Match).
21 *
22 * Without streaming, the devices except for Firewire Audiophile can mix any
23 * input and output. For this reason, Audiophile cannot be used as standalone
24 * mixer.
25 */
26
27#define MAUDIO_SPECIFIC_ADDRESS 0xffc700000000
28
29#define METER_OFFSET 0x00600000
30
31/* some device has sync info after metering data */
32#define METER_SIZE_FW410 76 /* with sync info */
33#define METER_SIZE_AUDIOPHILE 60 /* with sync info */
34#define METER_SIZE_SOLO 52 /* with sync info */
35#define METER_SIZE_OZONIC 48
36#define METER_SIZE_NRV10 80
37
38/* labels for metering */
39#define ANA_IN "Analog In"
40#define ANA_OUT "Analog Out"
41#define DIG_IN "Digital In"
42#define SPDIF_IN "S/PDIF In"
43#define ADAT_IN "ADAT In"
44#define DIG_OUT "Digital Out"
45#define SPDIF_OUT "S/PDIF Out"
46#define ADAT_OUT "ADAT Out"
47#define STRM_IN "Stream In"
48#define AUX_OUT "Aux Out"
49#define HP_OUT "HP Out"
50/* for NRV */
51#define UNKNOWN_METER "Unknown"
52
53static inline int
54get_meter(struct snd_bebob *bebob, void *buf, unsigned int size)
55{
56 return snd_fw_transaction(bebob->unit, TCODE_READ_BLOCK_REQUEST,
57 MAUDIO_SPECIFIC_ADDRESS + METER_OFFSET,
58 buf, size, 0);
59}
60
61/* last 4 bytes are omitted because it's clock info. */
62static char *const fw410_meter_labels[] = {
63 ANA_IN, DIG_IN,
64 ANA_OUT, ANA_OUT, ANA_OUT, ANA_OUT, DIG_OUT,
65 HP_OUT
66};
67static char *const audiophile_meter_labels[] = {
68 ANA_IN, DIG_IN,
69 ANA_OUT, ANA_OUT, DIG_OUT,
70 HP_OUT, AUX_OUT,
71};
72static char *const solo_meter_labels[] = {
73 ANA_IN, DIG_IN,
74 STRM_IN, STRM_IN,
75 ANA_OUT, DIG_OUT
76};
77
78/* no clock info */
79static char *const ozonic_meter_labels[] = {
80 ANA_IN, ANA_IN,
81 STRM_IN, STRM_IN,
82 ANA_OUT, ANA_OUT
83};
84/* TODO: need testers. these positions are based on authour's assumption */
85static char *const nrv10_meter_labels[] = {
86 ANA_IN, ANA_IN, ANA_IN, ANA_IN,
87 DIG_IN,
88 ANA_OUT, ANA_OUT, ANA_OUT, ANA_OUT,
89 DIG_IN
90};
91static int
92normal_meter_get(struct snd_bebob *bebob, u32 *buf, unsigned int size)
93{
94 struct snd_bebob_meter_spec *spec = bebob->spec->meter;
95 unsigned int c, channels;
96 int err;
97
98 channels = spec->num * 2;
99 if (size < channels * sizeof(u32))
100 return -EINVAL;
101
102 err = get_meter(bebob, (void *)buf, size);
103 if (err < 0)
104 goto end;
105
106 for (c = 0; c < channels; c++)
107 be32_to_cpus(&buf[c]);
108
109 /* swap stream channels because inverted */
110 if (spec->labels == solo_meter_labels) {
111 swap(buf[4], buf[6]);
112 swap(buf[5], buf[7]);
113 }
114end:
115 return err;
116}
117
118/* Firewire 410 specification */
119static struct snd_bebob_rate_spec usual_rate_spec = {
120 .get = &snd_bebob_stream_get_rate,
121 .set = &snd_bebob_stream_set_rate,
122};
123static struct snd_bebob_meter_spec fw410_meter_spec = {
124 .num = ARRAY_SIZE(fw410_meter_labels),
125 .labels = fw410_meter_labels,
126 .get = &normal_meter_get
127};
128struct snd_bebob_spec maudio_fw410_spec = {
129 .clock = NULL,
130 .rate = &usual_rate_spec,
131 .meter = &fw410_meter_spec
132};
133
134/* Firewire Audiophile specification */
135static struct snd_bebob_meter_spec audiophile_meter_spec = {
136 .num = ARRAY_SIZE(audiophile_meter_labels),
137 .labels = audiophile_meter_labels,
138 .get = &normal_meter_get
139};
140struct snd_bebob_spec maudio_audiophile_spec = {
141 .clock = NULL,
142 .rate = &usual_rate_spec,
143 .meter = &audiophile_meter_spec
144};
145
146/* Firewire Solo specification */
147static struct snd_bebob_meter_spec solo_meter_spec = {
148 .num = ARRAY_SIZE(solo_meter_labels),
149 .labels = solo_meter_labels,
150 .get = &normal_meter_get
151};
152struct snd_bebob_spec maudio_solo_spec = {
153 .clock = NULL,
154 .rate = &usual_rate_spec,
155 .meter = &solo_meter_spec
156};
157
158/* Ozonic specification */
159static struct snd_bebob_meter_spec ozonic_meter_spec = {
160 .num = ARRAY_SIZE(ozonic_meter_labels),
161 .labels = ozonic_meter_labels,
162 .get = &normal_meter_get
163};
164struct snd_bebob_spec maudio_ozonic_spec = {
165 .clock = NULL,
166 .rate = &usual_rate_spec,
167 .meter = &ozonic_meter_spec
168};
169
170/* NRV10 specification */
171static struct snd_bebob_meter_spec nrv10_meter_spec = {
172 .num = ARRAY_SIZE(nrv10_meter_labels),
173 .labels = nrv10_meter_labels,
174 .get = &normal_meter_get
175};
176struct snd_bebob_spec maudio_nrv10_spec = {
177 .clock = NULL,
178 .rate = &usual_rate_spec,
179 .meter = &nrv10_meter_spec
180};
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index 4a21dcf95d95..5fc52706f7c5 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -252,6 +252,15 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
252 /* location of this channel in this section */ 252 /* location of this channel in this section */
253 sec_loc = buf[pos++] - 1; 253 sec_loc = buf[pos++] - 1;
254 254
255 /*
256 * Basically the number of location is within the
257 * number of channels in this section. But some models
258 * of M-Audio don't follow this. Its location for MIDI
259 * is the position of MIDI channels in AMDTP packet.
260 */
261 if (sec_loc >= channels)
262 sec_loc = ch;
263
255 switch (type) { 264 switch (type) {
256 /* for MIDI conformant data channel */ 265 /* for MIDI conformant data channel */
257 case 0x0a: 266 case 0x0a: