Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 1 | /* |
| 2 | * bebob.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 | /* |
| 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. |
| 13 | */ |
| 14 | |
| 15 | #include "bebob.h" |
| 16 | |
| 17 | MODULE_DESCRIPTION("BridgeCo BeBoB driver"); |
| 18 | MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>"); |
| 19 | MODULE_LICENSE("GPL v2"); |
| 20 | |
| 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; |
| 24 | |
| 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"); |
| 31 | |
| 32 | static DEFINE_MUTEX(devices_mutex); |
| 33 | static DECLARE_BITMAP(devices_used, SNDRV_CARDS); |
| 34 | |
| 35 | /* Offsets from information register. */ |
Takashi Sakamoto | 7b4d7dc | 2015-06-14 12:49:33 +0900 | [diff] [blame] | 36 | #define INFO_OFFSET_BEBOB_VERSION 0x08 |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 37 | #define INFO_OFFSET_GUID 0x10 |
| 38 | #define INFO_OFFSET_HW_MODEL_ID 0x18 |
| 39 | #define INFO_OFFSET_HW_MODEL_REVISION 0x1c |
| 40 | |
| 41 | #define VEN_EDIROL 0x000040ab |
| 42 | #define VEN_PRESONUS 0x00000a92 |
| 43 | #define VEN_BRIDGECO 0x000007f5 |
Takashi Sakamoto | 425a570 | 2015-10-04 09:17:03 +0900 | [diff] [blame] | 44 | #define VEN_MACKIE1 0x0000000f |
| 45 | #define VEN_MACKIE2 0x00000ff2 |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 46 | #define VEN_STANTON 0x00001260 |
| 47 | #define VEN_TASCAM 0x0000022e |
| 48 | #define VEN_BEHRINGER 0x00001564 |
| 49 | #define VEN_APOGEE 0x000003db |
| 50 | #define VEN_ESI 0x00000f1b |
| 51 | #define VEN_ACOUSTIC 0x00000002 |
| 52 | #define VEN_CME 0x0000000a |
| 53 | #define VEN_PHONIC 0x00001496 |
| 54 | #define VEN_LYNX 0x000019e5 |
| 55 | #define VEN_ICON 0x00001a9e |
| 56 | #define VEN_PRISMSOUND 0x00001198 |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 57 | #define VEN_TERRATEC 0x00000aac |
Takashi Sakamoto | 8ac98a3 | 2014-04-25 22:45:23 +0900 | [diff] [blame] | 58 | #define VEN_YAMAHA 0x0000a0de |
Takashi Sakamoto | 25784ec | 2014-04-25 22:45:24 +0900 | [diff] [blame] | 59 | #define VEN_FOCUSRITE 0x0000130e |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 60 | #define VEN_MAUDIO1 0x00000d6c |
| 61 | #define VEN_MAUDIO2 0x000007f5 |
Takashi Sakamoto | 146a5e3 | 2015-05-24 20:51:45 +0900 | [diff] [blame] | 62 | #define VEN_DIGIDESIGN 0x00a07e |
Takashi Sakamoto | 25784ec | 2014-04-25 22:45:24 +0900 | [diff] [blame] | 63 | |
| 64 | #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000 |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 65 | #define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060 |
Takashi Sakamoto | 3149ac4 | 2014-04-25 22:45:26 +0900 | [diff] [blame] | 66 | #define MODEL_MAUDIO_FW1814 0x00010071 |
| 67 | #define MODEL_MAUDIO_PROJECTMIX 0x00010091 |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 68 | |
| 69 | static int |
Takashi Sakamoto | 093dd44 | 2016-03-27 16:09:06 +0900 | [diff] [blame] | 70 | name_device(struct snd_bebob *bebob) |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 71 | { |
| 72 | struct fw_device *fw_dev = fw_parent_device(bebob->unit); |
| 73 | char vendor[24] = {0}; |
| 74 | char model[32] = {0}; |
Takashi Sakamoto | 791c67b | 2014-05-28 00:14:44 +0900 | [diff] [blame] | 75 | u32 hw_id; |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 76 | u32 data[2] = {0}; |
| 77 | u32 revision; |
Takashi Sakamoto | 7b4d7dc | 2015-06-14 12:49:33 +0900 | [diff] [blame] | 78 | u32 version; |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 79 | int err; |
| 80 | |
| 81 | /* get vendor name from root directory */ |
| 82 | err = fw_csr_string(fw_dev->config_rom + 5, CSR_VENDOR, |
| 83 | vendor, sizeof(vendor)); |
| 84 | if (err < 0) |
| 85 | goto end; |
| 86 | |
| 87 | /* get model name from unit directory */ |
| 88 | err = fw_csr_string(bebob->unit->directory, CSR_MODEL, |
| 89 | model, sizeof(model)); |
| 90 | if (err < 0) |
| 91 | goto end; |
| 92 | |
| 93 | /* get hardware id */ |
| 94 | err = snd_bebob_read_quad(bebob->unit, INFO_OFFSET_HW_MODEL_ID, |
Takashi Sakamoto | 791c67b | 2014-05-28 00:14:44 +0900 | [diff] [blame] | 95 | &hw_id); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 96 | if (err < 0) |
| 97 | goto end; |
| 98 | |
| 99 | /* get hardware revision */ |
| 100 | err = snd_bebob_read_quad(bebob->unit, INFO_OFFSET_HW_MODEL_REVISION, |
| 101 | &revision); |
| 102 | if (err < 0) |
| 103 | goto end; |
| 104 | |
| 105 | /* get GUID */ |
| 106 | err = snd_bebob_read_block(bebob->unit, INFO_OFFSET_GUID, |
| 107 | data, sizeof(data)); |
| 108 | if (err < 0) |
| 109 | goto end; |
| 110 | |
Takashi Sakamoto | 7b4d7dc | 2015-06-14 12:49:33 +0900 | [diff] [blame] | 111 | err = snd_bebob_read_quad(bebob->unit, INFO_OFFSET_BEBOB_VERSION, |
| 112 | &version); |
| 113 | if (err < 0) |
| 114 | goto end; |
| 115 | bebob->version = version; |
| 116 | |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 117 | strcpy(bebob->card->driver, "BeBoB"); |
| 118 | strcpy(bebob->card->shortname, model); |
| 119 | strcpy(bebob->card->mixername, model); |
| 120 | snprintf(bebob->card->longname, sizeof(bebob->card->longname), |
| 121 | "%s %s (id:%d, rev:%d), GUID %08x%08x at %s, S%d", |
Takashi Sakamoto | 791c67b | 2014-05-28 00:14:44 +0900 | [diff] [blame] | 122 | vendor, model, hw_id, revision, |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 123 | data[0], data[1], dev_name(&bebob->unit->device), |
| 124 | 100 << fw_dev->max_speed); |
| 125 | end: |
| 126 | return err; |
| 127 | } |
| 128 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 129 | static void bebob_free(struct snd_bebob *bebob) |
| 130 | { |
| 131 | snd_bebob_stream_destroy_duplex(bebob); |
| 132 | fw_unit_put(bebob->unit); |
| 133 | |
| 134 | kfree(bebob->maudio_special_quirk); |
| 135 | |
| 136 | mutex_destroy(&bebob->mutex); |
| 137 | kfree(bebob); |
| 138 | } |
| 139 | |
Takashi Sakamoto | 12ed719 | 2015-02-21 23:54:57 +0900 | [diff] [blame] | 140 | /* |
| 141 | * This module releases the FireWire unit data after all ALSA character devices |
| 142 | * are released by applications. This is for releasing stream data or finishing |
| 143 | * transactions safely. Thus at returning from .remove(), this module still keep |
| 144 | * references for the unit. |
| 145 | */ |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 146 | static void |
| 147 | bebob_card_free(struct snd_card *card) |
| 148 | { |
| 149 | struct snd_bebob *bebob = card->private_data; |
| 150 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 151 | mutex_lock(&devices_mutex); |
| 152 | clear_bit(bebob->card_index, devices_used); |
| 153 | mutex_unlock(&devices_mutex); |
Takashi Sakamoto | 12ed719 | 2015-02-21 23:54:57 +0900 | [diff] [blame] | 154 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 155 | bebob_free(card->private_data); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 156 | } |
| 157 | |
Takashi Sakamoto | 25784ec | 2014-04-25 22:45:24 +0900 | [diff] [blame] | 158 | static const struct snd_bebob_spec * |
| 159 | get_saffire_spec(struct fw_unit *unit) |
| 160 | { |
| 161 | char name[24] = {0}; |
| 162 | |
| 163 | if (fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)) < 0) |
| 164 | return NULL; |
| 165 | |
| 166 | if (strcmp(name, "SaffireLE") == 0) |
| 167 | return &saffire_le_spec; |
| 168 | else |
| 169 | return &saffire_spec; |
| 170 | } |
| 171 | |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 172 | static bool |
| 173 | check_audiophile_booted(struct fw_unit *unit) |
| 174 | { |
Takashi Sakamoto | 2e57069 | 2016-11-18 06:11:24 +0900 | [diff] [blame] | 175 | char name[28] = {0}; |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 176 | |
| 177 | if (fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)) < 0) |
| 178 | return false; |
| 179 | |
Takashi Sakamoto | 2e57069 | 2016-11-18 06:11:24 +0900 | [diff] [blame] | 180 | return strncmp(name, "FW Audiophile Bootloader", 24) != 0; |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 181 | } |
| 182 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 183 | static void |
| 184 | do_registration(struct work_struct *work) |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 185 | { |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 186 | struct snd_bebob *bebob = |
| 187 | container_of(work, struct snd_bebob, dwork.work); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 188 | unsigned int card_index; |
| 189 | int err; |
| 190 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 191 | if (bebob->registered) |
| 192 | return; |
| 193 | |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 194 | mutex_lock(&devices_mutex); |
| 195 | |
| 196 | for (card_index = 0; card_index < SNDRV_CARDS; card_index++) { |
| 197 | if (!test_bit(card_index, devices_used) && enable[card_index]) |
| 198 | break; |
| 199 | } |
| 200 | if (card_index >= SNDRV_CARDS) { |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 201 | mutex_unlock(&devices_mutex); |
| 202 | return; |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 203 | } |
| 204 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 205 | err = snd_card_new(&bebob->unit->device, index[card_index], |
| 206 | id[card_index], THIS_MODULE, 0, &bebob->card); |
| 207 | if (err < 0) { |
| 208 | mutex_unlock(&devices_mutex); |
| 209 | return; |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 210 | } |
| 211 | |
Takashi Sakamoto | 093dd44 | 2016-03-27 16:09:06 +0900 | [diff] [blame] | 212 | err = name_device(bebob); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 213 | if (err < 0) |
| 214 | goto error; |
| 215 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 216 | if (bebob->spec == &maudio_special_spec) { |
| 217 | if (bebob->entry->model_id == MODEL_MAUDIO_FW1814) |
| 218 | err = snd_bebob_maudio_special_discover(bebob, true); |
| 219 | else |
| 220 | err = snd_bebob_maudio_special_discover(bebob, false); |
| 221 | } else { |
Takashi Sakamoto | 3149ac4 | 2014-04-25 22:45:26 +0900 | [diff] [blame] | 222 | err = snd_bebob_stream_discover(bebob); |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 223 | } |
| 224 | if (err < 0) |
| 225 | goto error; |
| 226 | |
| 227 | err = snd_bebob_stream_init_duplex(bebob); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 228 | if (err < 0) |
| 229 | goto error; |
Takashi Sakamoto | eb7b3a0 | 2014-04-25 22:45:15 +0900 | [diff] [blame] | 230 | |
Takashi Sakamoto | ad9697b | 2014-04-25 22:45:17 +0900 | [diff] [blame] | 231 | snd_bebob_proc_init(bebob); |
| 232 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 233 | if (bebob->midi_input_ports > 0 || bebob->midi_output_ports > 0) { |
Takashi Sakamoto | 248b780 | 2014-04-25 22:45:18 +0900 | [diff] [blame] | 234 | err = snd_bebob_create_midi_devices(bebob); |
| 235 | if (err < 0) |
| 236 | goto error; |
| 237 | } |
| 238 | |
Takashi Sakamoto | fbbebd2 | 2014-04-25 22:45:19 +0900 | [diff] [blame] | 239 | err = snd_bebob_create_pcm_devices(bebob); |
| 240 | if (err < 0) |
| 241 | goto error; |
| 242 | |
Takashi Sakamoto | 618eabe | 2014-04-25 22:45:20 +0900 | [diff] [blame] | 243 | err = snd_bebob_create_hwdep_device(bebob); |
| 244 | if (err < 0) |
| 245 | goto error; |
| 246 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 247 | err = snd_card_register(bebob->card); |
Takashi Sakamoto | eb7b3a0 | 2014-04-25 22:45:15 +0900 | [diff] [blame] | 248 | if (err < 0) |
| 249 | goto error; |
| 250 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 251 | set_bit(card_index, devices_used); |
| 252 | mutex_unlock(&devices_mutex); |
| 253 | |
| 254 | /* |
| 255 | * After registered, bebob instance can be released corresponding to |
| 256 | * releasing the sound card instance. |
| 257 | */ |
| 258 | bebob->card->private_free = bebob_card_free; |
| 259 | bebob->card->private_data = bebob; |
| 260 | bebob->registered = true; |
| 261 | |
| 262 | return; |
| 263 | error: |
| 264 | mutex_unlock(&devices_mutex); |
| 265 | snd_bebob_stream_destroy_duplex(bebob); |
| 266 | snd_card_free(bebob->card); |
| 267 | dev_info(&bebob->unit->device, |
| 268 | "Sound card registration failed: %d\n", err); |
| 269 | } |
| 270 | |
| 271 | static int |
| 272 | bebob_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) |
| 273 | { |
| 274 | struct snd_bebob *bebob; |
| 275 | const struct snd_bebob_spec *spec; |
| 276 | |
| 277 | if (entry->vendor_id == VEN_FOCUSRITE && |
| 278 | entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH) |
| 279 | spec = get_saffire_spec(unit); |
| 280 | else if (entry->vendor_id == VEN_MAUDIO1 && |
| 281 | entry->model_id == MODEL_MAUDIO_AUDIOPHILE_BOTH && |
| 282 | !check_audiophile_booted(unit)) |
| 283 | spec = NULL; |
| 284 | else |
| 285 | spec = (const struct snd_bebob_spec *)entry->driver_data; |
| 286 | |
| 287 | if (spec == NULL) { |
| 288 | if (entry->vendor_id == VEN_MAUDIO1 || |
| 289 | entry->vendor_id == VEN_MAUDIO2) |
| 290 | return snd_bebob_maudio_load_firmware(unit); |
| 291 | else |
| 292 | return -ENODEV; |
| 293 | } |
| 294 | |
| 295 | /* Allocate this independent of sound card instance. */ |
| 296 | bebob = kzalloc(sizeof(struct snd_bebob), GFP_KERNEL); |
| 297 | if (bebob == NULL) |
| 298 | return -ENOMEM; |
| 299 | |
| 300 | bebob->unit = fw_unit_get(unit); |
| 301 | bebob->entry = entry; |
| 302 | bebob->spec = spec; |
| 303 | dev_set_drvdata(&unit->device, bebob); |
| 304 | |
| 305 | mutex_init(&bebob->mutex); |
| 306 | spin_lock_init(&bebob->lock); |
| 307 | init_waitqueue_head(&bebob->hwdep_wait); |
| 308 | |
| 309 | /* Allocate and register this sound card later. */ |
| 310 | INIT_DEFERRABLE_WORK(&bebob->dwork, do_registration); |
| 311 | |
| 312 | if (entry->vendor_id != VEN_MAUDIO1 || |
| 313 | (entry->model_id != MODEL_MAUDIO_FW1814 && |
| 314 | entry->model_id != MODEL_MAUDIO_PROJECTMIX)) { |
| 315 | snd_fw_schedule_registration(unit, &bebob->dwork); |
Takashi Sakamoto | 9b1ee0b | 2014-04-25 22:45:30 +0900 | [diff] [blame] | 316 | } else { |
| 317 | /* |
| 318 | * This is a workaround. This bus reset seems to have an effect |
| 319 | * to make devices correctly handling transactions. Without |
| 320 | * this, the devices have gap_count mismatch. This causes much |
| 321 | * failure of transaction. |
| 322 | * |
| 323 | * Just after registration, user-land application receive |
| 324 | * signals from dbus and starts I/Os. To avoid I/Os till the |
| 325 | * future bus reset, registration is done in next update(). |
| 326 | */ |
Takashi Sakamoto | 9b1ee0b | 2014-04-25 22:45:30 +0900 | [diff] [blame] | 327 | fw_schedule_bus_reset(fw_parent_device(bebob->unit)->card, |
| 328 | false, true); |
Takashi Sakamoto | eb7b3a0 | 2014-04-25 22:45:15 +0900 | [diff] [blame] | 329 | } |
| 330 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 331 | return 0; |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 332 | } |
| 333 | |
Takashi Sakamoto | 3800e6f | 2016-02-20 16:18:59 +0900 | [diff] [blame] | 334 | /* |
| 335 | * This driver doesn't update streams in bus reset handler. |
| 336 | * |
| 337 | * DM1000/ DM1100/DM1500 chipsets with BeBoB firmware transfer packets with |
| 338 | * discontinued counter at bus reset. This discontinuity is immediately |
| 339 | * detected in packet streaming layer, then it sets XRUN to PCM substream. |
| 340 | * |
| 341 | * ALSA PCM applications can know the XRUN by getting -EPIPE from PCM operation. |
| 342 | * Then, they can recover the PCM substream by executing ioctl(2) with |
| 343 | * SNDRV_PCM_IOCTL_PREPARE. 'struct snd_pcm_ops.prepare' is called and drivers |
| 344 | * restart packet streaming. |
| 345 | * |
| 346 | * The above processing may be executed before this bus-reset handler is |
| 347 | * executed. When this handler updates streams with current isochronous |
| 348 | * channels, the streams already have the current ones. |
| 349 | */ |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 350 | static void |
| 351 | bebob_update(struct fw_unit *unit) |
| 352 | { |
| 353 | struct snd_bebob *bebob = dev_get_drvdata(&unit->device); |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 354 | |
| 355 | if (bebob == NULL) |
| 356 | return; |
| 357 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 358 | /* Postpone a workqueue for deferred registration. */ |
| 359 | if (!bebob->registered) |
| 360 | snd_fw_schedule_registration(unit, &bebob->dwork); |
| 361 | else |
| 362 | fcp_bus_reset(bebob->unit); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | static void bebob_remove(struct fw_unit *unit) |
| 366 | { |
| 367 | struct snd_bebob *bebob = dev_get_drvdata(&unit->device); |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 368 | |
| 369 | if (bebob == NULL) |
| 370 | return; |
| 371 | |
Takashi Sakamoto | 04a2c73 | 2016-03-31 08:47:05 +0900 | [diff] [blame] | 372 | /* |
| 373 | * Confirm to stop the work for registration before the sound card is |
| 374 | * going to be released. The work is not scheduled again because bus |
| 375 | * reset handler is not called anymore. |
| 376 | */ |
| 377 | cancel_delayed_work_sync(&bebob->dwork); |
| 378 | |
| 379 | if (bebob->registered) { |
| 380 | /* No need to wait for releasing card object in this context. */ |
| 381 | snd_card_free_when_closed(bebob->card); |
| 382 | } else { |
| 383 | /* Don't forget this case. */ |
| 384 | bebob_free(bebob); |
| 385 | } |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 386 | } |
| 387 | |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame] | 388 | static const struct snd_bebob_rate_spec normal_rate_spec = { |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 389 | .get = &snd_bebob_stream_get_rate, |
| 390 | .set = &snd_bebob_stream_set_rate |
| 391 | }; |
| 392 | static const struct snd_bebob_spec spec_normal = { |
| 393 | .clock = NULL, |
| 394 | .rate = &normal_rate_spec, |
| 395 | .meter = NULL |
| 396 | }; |
| 397 | |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 398 | static const struct ieee1394_device_id bebob_id_table[] = { |
| 399 | /* Edirol, FA-66 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 400 | SND_BEBOB_DEV_ENTRY(VEN_EDIROL, 0x00010049, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 401 | /* Edirol, FA-101 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 402 | SND_BEBOB_DEV_ENTRY(VEN_EDIROL, 0x00010048, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 403 | /* Presonus, FIREBOX */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 404 | SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 405 | /* PreSonus, FIREPOD/FP10 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 406 | SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010066, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 407 | /* PreSonus, Inspire1394 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 408 | SND_BEBOB_DEV_ENTRY(VEN_PRESONUS, 0x00010001, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 409 | /* BridgeCo, RDAudio1 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 410 | SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010048, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 411 | /* BridgeCo, Audio5 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 412 | SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010049, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 413 | /* Mackie, Onyx 1220/1620/1640 (Firewire I/O Card) */ |
Takashi Sakamoto | 425a570 | 2015-10-04 09:17:03 +0900 | [diff] [blame] | 414 | SND_BEBOB_DEV_ENTRY(VEN_MACKIE2, 0x00010065, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 415 | /* Mackie, d.2 (Firewire Option) */ |
Takashi Sakamoto | 425a570 | 2015-10-04 09:17:03 +0900 | [diff] [blame] | 416 | SND_BEBOB_DEV_ENTRY(VEN_MACKIE1, 0x00010067, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 417 | /* Stanton, ScratchAmp */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 418 | SND_BEBOB_DEV_ENTRY(VEN_STANTON, 0x00000001, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 419 | /* Tascam, IF-FW DM */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 420 | SND_BEBOB_DEV_ENTRY(VEN_TASCAM, 0x00010067, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 421 | /* Behringer, XENIX UFX 1204 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 422 | SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00001204, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 423 | /* Behringer, XENIX UFX 1604 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 424 | SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00001604, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 425 | /* Behringer, Digital Mixer X32 series (X-UF Card) */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 426 | SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x00000006, &spec_normal), |
Takashi Sakamoto | cf8a471 | 2015-06-14 12:49:37 +0900 | [diff] [blame] | 427 | /* Behringer, F-Control Audio 1616 */ |
| 428 | SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x001616, &spec_normal), |
| 429 | /* Behringer, F-Control Audio 610 */ |
| 430 | SND_BEBOB_DEV_ENTRY(VEN_BEHRINGER, 0x000610, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 431 | /* Apogee Electronics, Rosetta 200/400 (X-FireWire card) */ |
| 432 | /* Apogee Electronics, DA/AD/DD-16X (X-FireWire card) */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 433 | SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00010048, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 434 | /* Apogee Electronics, Ensemble */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 435 | SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00001eee, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 436 | /* ESI, Quatafire610 */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 437 | SND_BEBOB_DEV_ENTRY(VEN_ESI, 0x00010064, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 438 | /* AcousticReality, eARMasterOne */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 439 | SND_BEBOB_DEV_ENTRY(VEN_ACOUSTIC, 0x00000002, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 440 | /* CME, MatrixKFW */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 441 | SND_BEBOB_DEV_ENTRY(VEN_CME, 0x00030000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 442 | /* Phonic, Helix Board 12 MkII */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 443 | SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00050000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 444 | /* Phonic, Helix Board 18 MkII */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 445 | SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00060000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 446 | /* Phonic, Helix Board 24 MkII */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 447 | SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00070000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 448 | /* Phonic, Helix Board 12 Universal/18 Universal/24 Universal */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 449 | SND_BEBOB_DEV_ENTRY(VEN_PHONIC, 0x00000000, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 450 | /* Lynx, Aurora 8/16 (LT-FW) */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 451 | SND_BEBOB_DEV_ENTRY(VEN_LYNX, 0x00000001, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 452 | /* ICON, FireXon */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 453 | SND_BEBOB_DEV_ENTRY(VEN_ICON, 0x00000001, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 454 | /* PrismSound, Orpheus */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 455 | SND_BEBOB_DEV_ENTRY(VEN_PRISMSOUND, 0x00010048, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 456 | /* PrismSound, ADA-8XR */ |
Takashi Sakamoto | 1fc9522 | 2014-04-25 22:45:21 +0900 | [diff] [blame] | 457 | SND_BEBOB_DEV_ENTRY(VEN_PRISMSOUND, 0x0000ada8, &spec_normal), |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 458 | /* TerraTec Electronic GmbH, PHASE 88 Rack FW */ |
| 459 | SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000003, &phase88_rack_spec), |
| 460 | /* TerraTec Electronic GmbH, PHASE 24 FW */ |
Takashi Sakamoto | e15c282 | 2016-08-24 21:42:43 +0900 | [diff] [blame] | 461 | SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000004, &yamaha_terratec_spec), |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 462 | /* TerraTec Electronic GmbH, Phase X24 FW */ |
Takashi Sakamoto | e15c282 | 2016-08-24 21:42:43 +0900 | [diff] [blame] | 463 | SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000007, &yamaha_terratec_spec), |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 464 | /* TerraTec Electronic GmbH, EWS MIC2/MIC8 */ |
| 465 | SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000005, &spec_normal), |
| 466 | /* Terratec Electronic GmbH, Aureon 7.1 Firewire */ |
| 467 | SND_BEBOB_DEV_ENTRY(VEN_TERRATEC, 0x00000002, &spec_normal), |
Takashi Sakamoto | 8ac98a3 | 2014-04-25 22:45:23 +0900 | [diff] [blame] | 468 | /* Yamaha, GO44 */ |
Takashi Sakamoto | e15c282 | 2016-08-24 21:42:43 +0900 | [diff] [blame] | 469 | SND_BEBOB_DEV_ENTRY(VEN_YAMAHA, 0x0010000b, &yamaha_terratec_spec), |
Takashi Sakamoto | 8ac98a3 | 2014-04-25 22:45:23 +0900 | [diff] [blame] | 470 | /* YAMAHA, GO46 */ |
Takashi Sakamoto | e15c282 | 2016-08-24 21:42:43 +0900 | [diff] [blame] | 471 | SND_BEBOB_DEV_ENTRY(VEN_YAMAHA, 0x0010000c, &yamaha_terratec_spec), |
Takashi Sakamoto | 25784ec | 2014-04-25 22:45:24 +0900 | [diff] [blame] | 472 | /* Focusrite, SaffirePro 26 I/O */ |
| 473 | SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000003, &saffirepro_26_spec), |
| 474 | /* Focusrite, SaffirePro 10 I/O */ |
| 475 | SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000006, &saffirepro_10_spec), |
| 476 | /* Focusrite, Saffire(no label and LE) */ |
| 477 | SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, MODEL_FOCUSRITE_SAFFIRE_BOTH, |
| 478 | &saffire_spec), |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 479 | /* M-Audio, Firewire 410 */ |
Takashi Sakamoto | a2b2a77 | 2014-04-25 22:45:29 +0900 | [diff] [blame] | 480 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO2, 0x00010058, NULL), /* bootloader */ |
Takashi Sakamoto | 9076c22 | 2014-04-25 22:45:25 +0900 | [diff] [blame] | 481 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO2, 0x00010046, &maudio_fw410_spec), |
| 482 | /* M-Audio, Firewire Audiophile */ |
| 483 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_AUDIOPHILE_BOTH, |
| 484 | &maudio_audiophile_spec), |
| 485 | /* M-Audio, Firewire Solo */ |
| 486 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010062, &maudio_solo_spec), |
| 487 | /* M-Audio, Ozonic */ |
| 488 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x0000000a, &maudio_ozonic_spec), |
| 489 | /* M-Audio NRV10 */ |
| 490 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010081, &maudio_nrv10_spec), |
| 491 | /* M-Audio, ProFireLightbridge */ |
| 492 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x000100a1, &spec_normal), |
Takashi Sakamoto | 3149ac4 | 2014-04-25 22:45:26 +0900 | [diff] [blame] | 493 | /* Firewire 1814 */ |
Takashi Sakamoto | a2b2a77 | 2014-04-25 22:45:29 +0900 | [diff] [blame] | 494 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010070, NULL), /* bootloader */ |
Takashi Sakamoto | 3149ac4 | 2014-04-25 22:45:26 +0900 | [diff] [blame] | 495 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_FW1814, |
| 496 | &maudio_special_spec), |
| 497 | /* M-Audio ProjectMix */ |
| 498 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_PROJECTMIX, |
| 499 | &maudio_special_spec), |
Takashi Sakamoto | 146a5e3 | 2015-05-24 20:51:45 +0900 | [diff] [blame] | 500 | /* Digidesign Mbox 2 Pro */ |
| 501 | SND_BEBOB_DEV_ENTRY(VEN_DIGIDESIGN, 0x0000a9, &spec_normal), |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 502 | /* IDs are unknown but able to be supported */ |
| 503 | /* Apogee, Mini-ME Firewire */ |
| 504 | /* Apogee, Mini-DAC Firewire */ |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 505 | /* Cakawalk, Sonar Power Studio 66 */ |
| 506 | /* CME, UF400e */ |
| 507 | /* ESI, Quotafire XL */ |
| 508 | /* Infrasonic, DewX */ |
| 509 | /* Infrasonic, Windy6 */ |
| 510 | /* Mackie, Digital X Bus x.200 */ |
| 511 | /* Mackie, Digital X Bus x.400 */ |
| 512 | /* Phonic, HB 12 */ |
| 513 | /* Phonic, HB 24 */ |
| 514 | /* Phonic, HB 18 */ |
| 515 | /* Phonic, FireFly 202 */ |
| 516 | /* Phonic, FireFly 302 */ |
| 517 | /* Rolf Spuler, Firewire Guitar */ |
| 518 | {} |
| 519 | }; |
| 520 | MODULE_DEVICE_TABLE(ieee1394, bebob_id_table); |
| 521 | |
| 522 | static struct fw_driver bebob_driver = { |
| 523 | .driver = { |
| 524 | .owner = THIS_MODULE, |
| 525 | .name = "snd-bebob", |
| 526 | .bus = &fw_bus_type, |
| 527 | }, |
| 528 | .probe = bebob_probe, |
| 529 | .update = bebob_update, |
| 530 | .remove = bebob_remove, |
| 531 | .id_table = bebob_id_table, |
| 532 | }; |
| 533 | |
| 534 | static int __init |
| 535 | snd_bebob_init(void) |
| 536 | { |
| 537 | return driver_register(&bebob_driver.driver); |
| 538 | } |
| 539 | |
| 540 | static void __exit |
| 541 | snd_bebob_exit(void) |
| 542 | { |
| 543 | driver_unregister(&bebob_driver.driver); |
Takashi Sakamoto | fd6f4b0d | 2014-04-25 22:45:14 +0900 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | module_init(snd_bebob_init); |
| 547 | module_exit(snd_bebob_exit); |