2 * bebob.c - a part of driver for BeBoB based devices
4 * Copyright (c) 2013-2014 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
10 * BeBoB is 'BridgeCo enhanced Breakout Box'. This is installed to firewire
11 * devices with DM1000/DM1100/DM1500 chipset. It gives common way for host
12 * system to handle BeBoB based devices.
17 MODULE_DESCRIPTION("BridgeCo BeBoB driver");
18 MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
19 MODULE_LICENSE("GPL v2");
21 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
22 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
23 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
25 module_param_array(index, int, NULL, 0444);
26 MODULE_PARM_DESC(index, "card index");
27 module_param_array(id, charp, NULL, 0444);
28 MODULE_PARM_DESC(id, "ID string");
29 module_param_array(enable, bool, NULL, 0444);
30 MODULE_PARM_DESC(enable, "enable BeBoB sound card");
32 static DEFINE_MUTEX(devices_mutex);
33 static DECLARE_BITMAP(devices_used, SNDRV_CARDS);
35 /* Offsets from information register. */
36 #define INFO_OFFSET_GUID 0x10
37 #define INFO_OFFSET_HW_MODEL_ID 0x18
38 #define INFO_OFFSET_HW_MODEL_REVISION 0x1c
40 #define VEN_EDIROL 0x000040ab
41 #define VEN_PRESONUS 0x00000a92
42 #define VEN_BRIDGECO 0x000007f5
43 #define VEN_MACKIE 0x0000000f
44 #define VEN_STANTON 0x00001260
45 #define VEN_TASCAM 0x0000022e
46 #define VEN_BEHRINGER 0x00001564
47 #define VEN_APOGEE 0x000003db
48 #define VEN_ESI 0x00000f1b
49 #define VEN_ACOUSTIC 0x00000002
50 #define VEN_CME 0x0000000a
51 #define VEN_PHONIC 0x00001496
52 #define VEN_LYNX 0x000019e5
53 #define VEN_ICON 0x00001a9e
54 #define VEN_PRISMSOUND 0x00001198
55 #define VEN_TERRATEC 0x00000aac
56 #define VEN_YAMAHA 0x0000a0de
57 #define VEN_FOCUSRITE 0x0000130e
59 #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000
62 name_device(struct snd_bebob *bebob, unsigned int vendor_id)
64 struct fw_device *fw_dev = fw_parent_device(bebob->unit);
65 char vendor[24] = {0};
72 /* get vendor name from root directory */
73 err = fw_csr_string(fw_dev->config_rom + 5, CSR_VENDOR,
74 vendor, sizeof(vendor));
78 /* get model name from unit directory */
79 err = fw_csr_string(bebob->unit->directory, CSR_MODEL,
80 model, sizeof(model));
85 err = snd_bebob_read_quad(bebob->unit, INFO_OFFSET_HW_MODEL_ID,
90 /* get hardware revision */
91 err = snd_bebob_read_quad(bebob->unit, INFO_OFFSET_HW_MODEL_REVISION,
97 err = snd_bebob_read_block(bebob->unit, INFO_OFFSET_GUID,
102 strcpy(bebob->card->driver, "BeBoB");
103 strcpy(bebob->card->shortname, model);
104 strcpy(bebob->card->mixername, model);
105 snprintf(bebob->card->longname, sizeof(bebob->card->longname),
106 "%s %s (id:%d, rev:%d), GUID %08x%08x at %s, S%d",
107 vendor, model, id, revision,
108 data[0], data[1], dev_name(&bebob->unit->device),
109 100 << fw_dev->max_speed);
115 bebob_card_free(struct snd_card *card)
117 struct snd_bebob *bebob = card->private_data;
119 if (bebob->card_index >= 0) {
120 mutex_lock(&devices_mutex);
121 clear_bit(bebob->card_index, devices_used);
122 mutex_unlock(&devices_mutex);
125 mutex_destroy(&bebob->mutex);
128 static const struct snd_bebob_spec *
129 get_saffire_spec(struct fw_unit *unit)
133 if (fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)) < 0)
136 if (strcmp(name, "SaffireLE") == 0)
137 return &saffire_le_spec;
139 return &saffire_spec;
143 bebob_probe(struct fw_unit *unit,
144 const struct ieee1394_device_id *entry)
146 struct snd_card *card;
147 struct snd_bebob *bebob;
148 const struct snd_bebob_spec *spec;
149 unsigned int card_index;
152 mutex_lock(&devices_mutex);
154 for (card_index = 0; card_index < SNDRV_CARDS; card_index++) {
155 if (!test_bit(card_index, devices_used) && enable[card_index])
158 if (card_index >= SNDRV_CARDS) {
163 if ((entry->vendor_id == VEN_FOCUSRITE) &&
164 (entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH))
165 spec = get_saffire_spec(unit);
167 spec = (const struct snd_bebob_spec *)entry->driver_data;
173 err = snd_card_new(&unit->device, index[card_index], id[card_index],
174 THIS_MODULE, sizeof(struct snd_bebob), &card);
177 bebob = card->private_data;
178 bebob->card_index = card_index;
179 set_bit(card_index, devices_used);
180 card->private_free = bebob_card_free;
185 mutex_init(&bebob->mutex);
186 spin_lock_init(&bebob->lock);
187 init_waitqueue_head(&bebob->hwdep_wait);
189 err = name_device(bebob, entry->vendor_id);
193 err = snd_bebob_stream_discover(bebob);
197 snd_bebob_proc_init(bebob);
199 if ((bebob->midi_input_ports > 0) ||
200 (bebob->midi_output_ports > 0)) {
201 err = snd_bebob_create_midi_devices(bebob);
206 err = snd_bebob_create_pcm_devices(bebob);
210 err = snd_bebob_create_hwdep_device(bebob);
214 err = snd_bebob_stream_init_duplex(bebob);
218 err = snd_card_register(card);
220 snd_bebob_stream_destroy_duplex(bebob);
224 dev_set_drvdata(&unit->device, bebob);
226 mutex_unlock(&devices_mutex);
229 mutex_unlock(&devices_mutex);
235 bebob_update(struct fw_unit *unit)
237 struct snd_bebob *bebob = dev_get_drvdata(&unit->device);
238 fcp_bus_reset(bebob->unit);
239 snd_bebob_stream_update_duplex(bebob);
242 static void bebob_remove(struct fw_unit *unit)
244 struct snd_bebob *bebob = dev_get_drvdata(&unit->device);
245 snd_bebob_stream_destroy_duplex(bebob);
246 snd_card_disconnect(bebob->card);
247 snd_card_free_when_closed(bebob->card);
250 struct snd_bebob_rate_spec normal_rate_spec = {
251 .get = &snd_bebob_stream_get_rate,
252 .set = &snd_bebob_stream_set_rate
254 static const struct snd_bebob_spec spec_normal = {
256 .rate = &normal_rate_spec,
260 static const struct ieee1394_device_id bebob_id_table[] = {
262 SND_BEBOB_DEV_ENTRY(VEN_EDIROL, 0x00010049, &spec_normal),
264 SND_BEBOB_DEV_ENTRY(VEN_EDIROL, 0x00010048, &spec_normal),
265 /* Presonus, FIREBOX */
266 SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010000, &spec_normal),
267 /* PreSonus, FIREPOD/FP10 */
268 SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010066, &spec_normal),
269 /* PreSonus, Inspire1394 */
270 SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010001, &spec_normal),
271 /* BridgeCo, RDAudio1 */
272 SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010048, &spec_normal),
273 /* BridgeCo, Audio5 */
274 SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010049, &spec_normal),
275 /* Mackie, Onyx 1220/1620/1640 (Firewire I/O Card) */
276 SND_BEBOB_DEV_ENTRY(VEN_MACKIE, 0x00010065, &spec_normal),
277 /* Mackie, d.2 (Firewire Option) */
278 SND_BEBOB_DEV_ENTRY(VEN_MACKIE, 0x00010067, &spec_normal),
279 /* Stanton, ScratchAmp */
280 SND_BEBOB_DEV_ENTRY(VEN_STANTON, 0x00000001, &spec_normal),
281 /* Tascam, IF-FW DM */
282 SND_BEBOB_DEV_ENTRY(VEN_TASCAM, 0x00010067, &spec_normal),
283 /* Behringer, XENIX UFX 1204 */
284 SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00001204, &spec_normal),
285 /* Behringer, XENIX UFX 1604 */
286 SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00001604, &spec_normal),
287 /* Behringer, Digital Mixer X32 series (X-UF Card) */
288 SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00000006, &spec_normal),
289 /* Apogee Electronics, Rosetta 200/400 (X-FireWire card) */
290 /* Apogee Electronics, DA/AD/DD-16X (X-FireWire card) */
291 SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00010048, &spec_normal),
292 /* Apogee Electronics, Ensemble */
293 SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00001eee, &spec_normal),
294 /* ESI, Quatafire610 */
295 SND_BEBOB_DEV_ENTRY(VEN_ESI, 0x00010064, &spec_normal),
296 /* AcousticReality, eARMasterOne */
297 SND_BEBOB_DEV_ENTRY(VEN_ACOUSTIC, 0x00000002, &spec_normal),
299 SND_BEBOB_DEV_ENTRY(VEN_CME, 0x00030000, &spec_normal),
300 /* Phonic, Helix Board 12 MkII */
301 SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00050000, &spec_normal),
302 /* Phonic, Helix Board 18 MkII */
303 SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00060000, &spec_normal),
304 /* Phonic, Helix Board 24 MkII */
305 SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00070000, &spec_normal),
306 /* Phonic, Helix Board 12 Universal/18 Universal/24 Universal */
307 SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00000000, &spec_normal),
308 /* Lynx, Aurora 8/16 (LT-FW) */
309 SND_BEBOB_DEV_ENTRY(VEN_LYNX, 0x00000001, &spec_normal),
311 SND_BEBOB_DEV_ENTRY(VEN_ICON, 0x00000001, &spec_normal),
312 /* PrismSound, Orpheus */
313 SND_BEBOB_DEV_ENTRY(VEN_PRISMSOUND, 0x00010048, &spec_normal),
314 /* PrismSound, ADA-8XR */
315 SND_BEBOB_DEV_ENTRY(VEN_PRISMSOUND, 0x0000ada8, &spec_normal),
316 /* TerraTec Electronic GmbH, PHASE 88 Rack FW */
317 SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000003, &phase88_rack_spec),
318 /* TerraTec Electronic GmbH, PHASE 24 FW */
319 SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000004, &phase24_series_spec),
320 /* TerraTec Electronic GmbH, Phase X24 FW */
321 SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000007, &phase24_series_spec),
322 /* TerraTec Electronic GmbH, EWS MIC2/MIC8 */
323 SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000005, &spec_normal),
324 /* Terratec Electronic GmbH, Aureon 7.1 Firewire */
325 SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000002, &spec_normal),
327 SND_BEBOB_DEV_ENTRY(VEN_YAMAHA, 0x0010000b, &yamaha_go_spec),
329 SND_BEBOB_DEV_ENTRY(VEN_YAMAHA, 0x0010000c, &yamaha_go_spec),
330 /* Focusrite, SaffirePro 26 I/O */
331 SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000003, &saffirepro_26_spec),
332 /* Focusrite, SaffirePro 10 I/O */
333 SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000006, &saffirepro_10_spec),
334 /* Focusrite, Saffire(no label and LE) */
335 SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, MODEL_FOCUSRITE_SAFFIRE_BOTH,
337 /* IDs are unknown but able to be supported */
338 /* Apogee, Mini-ME Firewire */
339 /* Apogee, Mini-DAC Firewire */
340 /* Behringer, F-Control Audio 1616 */
341 /* Behringer, F-Control Audio 610 */
342 /* Cakawalk, Sonar Power Studio 66 */
344 /* ESI, Quotafire XL */
345 /* Infrasonic, DewX */
346 /* Infrasonic, Windy6 */
347 /* Mackie, Digital X Bus x.200 */
348 /* Mackie, Digital X Bus x.400 */
352 /* Phonic, FireFly 202 */
353 /* Phonic, FireFly 302 */
354 /* Rolf Spuler, Firewire Guitar */
357 MODULE_DEVICE_TABLE(ieee1394, bebob_id_table);
359 static struct fw_driver bebob_driver = {
361 .owner = THIS_MODULE,
365 .probe = bebob_probe,
366 .update = bebob_update,
367 .remove = bebob_remove,
368 .id_table = bebob_id_table,
374 return driver_register(&bebob_driver.driver);
380 driver_unregister(&bebob_driver.driver);
381 mutex_destroy(&devices_mutex);
384 module_init(snd_bebob_init);
385 module_exit(snd_bebob_exit);