1 /* 2 * oxfw.c - a part of driver for OXFW970/971 based devices 3 * 4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 5 * Licensed under the terms of the GNU General Public License, version 2. 6 */ 7 8 #include <linux/device.h> 9 #include <linux/firewire.h> 10 #include <linux/firewire-constants.h> 11 #include <linux/module.h> 12 #include <linux/mod_devicetable.h> 13 #include <linux/mutex.h> 14 #include <linux/slab.h> 15 #include <sound/control.h> 16 #include <sound/core.h> 17 #include <sound/initval.h> 18 #include <sound/pcm.h> 19 #include <sound/pcm_params.h> 20 #include "../cmp.h" 21 #include "../fcp.h" 22 #include "../amdtp.h" 23 #include "../lib.h" 24 25 #define OXFORD_FIRMWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x50000) 26 /* 0x970?vvvv or 0x971?vvvv, where vvvv = firmware version */ 27 28 #define OXFORD_HARDWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x90020) 29 #define OXFORD_HARDWARE_ID_OXFW970 0x39443841 30 #define OXFORD_HARDWARE_ID_OXFW971 0x39373100 31 32 #define VENDOR_GRIFFIN 0x001292 33 #define VENDOR_LACIE 0x00d04b 34 35 #define SPECIFIER_1394TA 0x00a02d 36 #define VERSION_AVC 0x010001 37 38 struct device_info { 39 const char *driver_name; 40 const char *short_name; 41 const char *long_name; 42 int (*pcm_constraints)(struct snd_pcm_runtime *runtime); 43 unsigned int mixer_channels; 44 u8 mute_fb_id; 45 u8 volume_fb_id; 46 }; 47 48 struct snd_oxfw { 49 struct snd_card *card; 50 struct fw_unit *unit; 51 const struct device_info *device_info; 52 struct mutex mutex; 53 struct cmp_connection in_conn; 54 struct amdtp_stream rx_stream; 55 bool mute; 56 s16 volume[6]; 57 s16 volume_min; 58 s16 volume_max; 59 }; 60 61 MODULE_DESCRIPTION("Oxford Semiconductor FW970/971 driver"); 62 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 63 MODULE_LICENSE("GPL v2"); 64 MODULE_ALIAS("snd-firewire-speakers"); 65 66 static int firewave_rate_constraint(struct snd_pcm_hw_params *params, 67 struct snd_pcm_hw_rule *rule) 68 { 69 static unsigned int stereo_rates[] = { 48000, 96000 }; 70 struct snd_interval *channels = 71 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 72 struct snd_interval *rate = 73 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 74 75 /* two channels work only at 48/96 kHz */ 76 if (snd_interval_max(channels) < 6) 77 return snd_interval_list(rate, 2, stereo_rates, 0); 78 return 0; 79 } 80 81 static int firewave_channels_constraint(struct snd_pcm_hw_params *params, 82 struct snd_pcm_hw_rule *rule) 83 { 84 static const struct snd_interval all_channels = { .min = 6, .max = 6 }; 85 struct snd_interval *rate = 86 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 87 struct snd_interval *channels = 88 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 89 90 /* 32/44.1 kHz work only with all six channels */ 91 if (snd_interval_max(rate) < 48000) 92 return snd_interval_refine(channels, &all_channels); 93 return 0; 94 } 95 96 static int firewave_constraints(struct snd_pcm_runtime *runtime) 97 { 98 static unsigned int channels_list[] = { 2, 6 }; 99 static struct snd_pcm_hw_constraint_list channels_list_constraint = { 100 .count = 2, 101 .list = channels_list, 102 }; 103 int err; 104 105 runtime->hw.rates = SNDRV_PCM_RATE_32000 | 106 SNDRV_PCM_RATE_44100 | 107 SNDRV_PCM_RATE_48000 | 108 SNDRV_PCM_RATE_96000; 109 runtime->hw.channels_max = 6; 110 111 err = snd_pcm_hw_constraint_list(runtime, 0, 112 SNDRV_PCM_HW_PARAM_CHANNELS, 113 &channels_list_constraint); 114 if (err < 0) 115 return err; 116 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 117 firewave_rate_constraint, NULL, 118 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 119 if (err < 0) 120 return err; 121 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 122 firewave_channels_constraint, NULL, 123 SNDRV_PCM_HW_PARAM_RATE, -1); 124 if (err < 0) 125 return err; 126 127 return 0; 128 } 129 130 static int lacie_speakers_constraints(struct snd_pcm_runtime *runtime) 131 { 132 runtime->hw.rates = SNDRV_PCM_RATE_32000 | 133 SNDRV_PCM_RATE_44100 | 134 SNDRV_PCM_RATE_48000 | 135 SNDRV_PCM_RATE_88200 | 136 SNDRV_PCM_RATE_96000; 137 138 return 0; 139 } 140 141 static int oxfw_open(struct snd_pcm_substream *substream) 142 { 143 static const struct snd_pcm_hardware hardware = { 144 .info = SNDRV_PCM_INFO_MMAP | 145 SNDRV_PCM_INFO_MMAP_VALID | 146 SNDRV_PCM_INFO_BATCH | 147 SNDRV_PCM_INFO_INTERLEAVED | 148 SNDRV_PCM_INFO_BLOCK_TRANSFER, 149 .formats = AMDTP_OUT_PCM_FORMAT_BITS, 150 .channels_min = 2, 151 .channels_max = 2, 152 .buffer_bytes_max = 4 * 1024 * 1024, 153 .period_bytes_min = 1, 154 .period_bytes_max = UINT_MAX, 155 .periods_min = 1, 156 .periods_max = UINT_MAX, 157 }; 158 struct snd_oxfw *oxfw = substream->private_data; 159 struct snd_pcm_runtime *runtime = substream->runtime; 160 int err; 161 162 runtime->hw = hardware; 163 164 err = oxfw->device_info->pcm_constraints(runtime); 165 if (err < 0) 166 return err; 167 err = snd_pcm_limit_hw_rates(runtime); 168 if (err < 0) 169 return err; 170 171 err = amdtp_stream_add_pcm_hw_constraints(&oxfw->rx_stream, runtime); 172 if (err < 0) 173 return err; 174 175 return 0; 176 } 177 178 static int oxfw_close(struct snd_pcm_substream *substream) 179 { 180 return 0; 181 } 182 183 static void oxfw_stop_stream(struct snd_oxfw *oxfw) 184 { 185 if (amdtp_stream_running(&oxfw->rx_stream)) { 186 amdtp_stream_stop(&oxfw->rx_stream); 187 cmp_connection_break(&oxfw->in_conn); 188 } 189 } 190 191 static int oxfw_hw_params(struct snd_pcm_substream *substream, 192 struct snd_pcm_hw_params *hw_params) 193 { 194 struct snd_oxfw *oxfw = substream->private_data; 195 int err; 196 197 mutex_lock(&oxfw->mutex); 198 oxfw_stop_stream(oxfw); 199 mutex_unlock(&oxfw->mutex); 200 201 err = snd_pcm_lib_alloc_vmalloc_buffer(substream, 202 params_buffer_bytes(hw_params)); 203 if (err < 0) 204 goto error; 205 206 amdtp_stream_set_parameters(&oxfw->rx_stream, 207 params_rate(hw_params), 208 params_channels(hw_params), 209 0); 210 211 amdtp_stream_set_pcm_format(&oxfw->rx_stream, 212 params_format(hw_params)); 213 214 err = avc_general_set_sig_fmt(oxfw->unit, params_rate(hw_params), 215 AVC_GENERAL_PLUG_DIR_IN, 0); 216 if (err < 0) { 217 dev_err(&oxfw->unit->device, "failed to set sample rate\n"); 218 goto err_buffer; 219 } 220 221 return 0; 222 223 err_buffer: 224 snd_pcm_lib_free_vmalloc_buffer(substream); 225 error: 226 return err; 227 } 228 229 static int oxfw_hw_free(struct snd_pcm_substream *substream) 230 { 231 struct snd_oxfw *oxfw = substream->private_data; 232 233 mutex_lock(&oxfw->mutex); 234 oxfw_stop_stream(oxfw); 235 mutex_unlock(&oxfw->mutex); 236 237 return snd_pcm_lib_free_vmalloc_buffer(substream); 238 } 239 240 static int oxfw_prepare(struct snd_pcm_substream *substream) 241 { 242 struct snd_oxfw *oxfw = substream->private_data; 243 int err; 244 245 mutex_lock(&oxfw->mutex); 246 247 if (amdtp_streaming_error(&oxfw->rx_stream)) 248 oxfw_stop_stream(oxfw); 249 250 if (!amdtp_stream_running(&oxfw->rx_stream)) { 251 err = cmp_connection_establish(&oxfw->in_conn, 252 amdtp_stream_get_max_payload(&oxfw->rx_stream)); 253 if (err < 0) 254 goto err_mutex; 255 256 err = amdtp_stream_start(&oxfw->rx_stream, 257 oxfw->in_conn.resources.channel, 258 oxfw->in_conn.speed); 259 if (err < 0) 260 goto err_connection; 261 } 262 263 mutex_unlock(&oxfw->mutex); 264 265 amdtp_stream_pcm_prepare(&oxfw->rx_stream); 266 267 return 0; 268 269 err_connection: 270 cmp_connection_break(&oxfw->in_conn); 271 err_mutex: 272 mutex_unlock(&oxfw->mutex); 273 274 return err; 275 } 276 277 static int oxfw_trigger(struct snd_pcm_substream *substream, int cmd) 278 { 279 struct snd_oxfw *oxfw = substream->private_data; 280 struct snd_pcm_substream *pcm; 281 282 switch (cmd) { 283 case SNDRV_PCM_TRIGGER_START: 284 pcm = substream; 285 break; 286 case SNDRV_PCM_TRIGGER_STOP: 287 pcm = NULL; 288 break; 289 default: 290 return -EINVAL; 291 } 292 amdtp_stream_pcm_trigger(&oxfw->rx_stream, pcm); 293 return 0; 294 } 295 296 static snd_pcm_uframes_t oxfw_pointer(struct snd_pcm_substream *substream) 297 { 298 struct snd_oxfw *oxfw = substream->private_data; 299 300 return amdtp_stream_pcm_pointer(&oxfw->rx_stream); 301 } 302 303 static int oxfw_create_pcm(struct snd_oxfw *oxfw) 304 { 305 static struct snd_pcm_ops ops = { 306 .open = oxfw_open, 307 .close = oxfw_close, 308 .ioctl = snd_pcm_lib_ioctl, 309 .hw_params = oxfw_hw_params, 310 .hw_free = oxfw_hw_free, 311 .prepare = oxfw_prepare, 312 .trigger = oxfw_trigger, 313 .pointer = oxfw_pointer, 314 .page = snd_pcm_lib_get_vmalloc_page, 315 .mmap = snd_pcm_lib_mmap_vmalloc, 316 }; 317 struct snd_pcm *pcm; 318 int err; 319 320 err = snd_pcm_new(oxfw->card, "OXFW", 0, 1, 0, &pcm); 321 if (err < 0) 322 return err; 323 pcm->private_data = oxfw; 324 strcpy(pcm->name, oxfw->device_info->short_name); 325 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &ops); 326 return 0; 327 } 328 329 enum control_action { CTL_READ, CTL_WRITE }; 330 enum control_attribute { 331 CTL_MIN = 0x02, 332 CTL_MAX = 0x03, 333 CTL_CURRENT = 0x10, 334 }; 335 336 static int oxfw_mute_command(struct snd_oxfw *oxfw, bool *value, 337 enum control_action action) 338 { 339 u8 *buf; 340 u8 response_ok; 341 int err; 342 343 buf = kmalloc(11, GFP_KERNEL); 344 if (!buf) 345 return -ENOMEM; 346 347 if (action == CTL_READ) { 348 buf[0] = 0x01; /* AV/C, STATUS */ 349 response_ok = 0x0c; /* STABLE */ 350 } else { 351 buf[0] = 0x00; /* AV/C, CONTROL */ 352 response_ok = 0x09; /* ACCEPTED */ 353 } 354 buf[1] = 0x08; /* audio unit 0 */ 355 buf[2] = 0xb8; /* FUNCTION BLOCK */ 356 buf[3] = 0x81; /* function block type: feature */ 357 buf[4] = oxfw->device_info->mute_fb_id; /* function block ID */ 358 buf[5] = 0x10; /* control attribute: current */ 359 buf[6] = 0x02; /* selector length */ 360 buf[7] = 0x00; /* audio channel number */ 361 buf[8] = 0x01; /* control selector: mute */ 362 buf[9] = 0x01; /* control data length */ 363 if (action == CTL_READ) 364 buf[10] = 0xff; 365 else 366 buf[10] = *value ? 0x70 : 0x60; 367 368 err = fcp_avc_transaction(oxfw->unit, buf, 11, buf, 11, 0x3fe); 369 if (err < 0) 370 goto error; 371 if (err < 11) { 372 dev_err(&oxfw->unit->device, "short FCP response\n"); 373 err = -EIO; 374 goto error; 375 } 376 if (buf[0] != response_ok) { 377 dev_err(&oxfw->unit->device, "mute command failed\n"); 378 err = -EIO; 379 goto error; 380 } 381 if (action == CTL_READ) 382 *value = buf[10] == 0x70; 383 384 err = 0; 385 386 error: 387 kfree(buf); 388 389 return err; 390 } 391 392 static int oxfw_volume_command(struct snd_oxfw *oxfw, s16 *value, 393 unsigned int channel, 394 enum control_attribute attribute, 395 enum control_action action) 396 { 397 u8 *buf; 398 u8 response_ok; 399 int err; 400 401 buf = kmalloc(12, GFP_KERNEL); 402 if (!buf) 403 return -ENOMEM; 404 405 if (action == CTL_READ) { 406 buf[0] = 0x01; /* AV/C, STATUS */ 407 response_ok = 0x0c; /* STABLE */ 408 } else { 409 buf[0] = 0x00; /* AV/C, CONTROL */ 410 response_ok = 0x09; /* ACCEPTED */ 411 } 412 buf[1] = 0x08; /* audio unit 0 */ 413 buf[2] = 0xb8; /* FUNCTION BLOCK */ 414 buf[3] = 0x81; /* function block type: feature */ 415 buf[4] = oxfw->device_info->volume_fb_id; /* function block ID */ 416 buf[5] = attribute; /* control attribute */ 417 buf[6] = 0x02; /* selector length */ 418 buf[7] = channel; /* audio channel number */ 419 buf[8] = 0x02; /* control selector: volume */ 420 buf[9] = 0x02; /* control data length */ 421 if (action == CTL_READ) { 422 buf[10] = 0xff; 423 buf[11] = 0xff; 424 } else { 425 buf[10] = *value >> 8; 426 buf[11] = *value; 427 } 428 429 err = fcp_avc_transaction(oxfw->unit, buf, 12, buf, 12, 0x3fe); 430 if (err < 0) 431 goto error; 432 if (err < 12) { 433 dev_err(&oxfw->unit->device, "short FCP response\n"); 434 err = -EIO; 435 goto error; 436 } 437 if (buf[0] != response_ok) { 438 dev_err(&oxfw->unit->device, "volume command failed\n"); 439 err = -EIO; 440 goto error; 441 } 442 if (action == CTL_READ) 443 *value = (buf[10] << 8) | buf[11]; 444 445 err = 0; 446 447 error: 448 kfree(buf); 449 450 return err; 451 } 452 453 static int oxfw_mute_get(struct snd_kcontrol *control, 454 struct snd_ctl_elem_value *value) 455 { 456 struct snd_oxfw *oxfw = control->private_data; 457 458 value->value.integer.value[0] = !oxfw->mute; 459 460 return 0; 461 } 462 463 static int oxfw_mute_put(struct snd_kcontrol *control, 464 struct snd_ctl_elem_value *value) 465 { 466 struct snd_oxfw *oxfw = control->private_data; 467 bool mute; 468 int err; 469 470 mute = !value->value.integer.value[0]; 471 472 if (mute == oxfw->mute) 473 return 0; 474 475 err = oxfw_mute_command(oxfw, &mute, CTL_WRITE); 476 if (err < 0) 477 return err; 478 oxfw->mute = mute; 479 480 return 1; 481 } 482 483 static int oxfw_volume_info(struct snd_kcontrol *control, 484 struct snd_ctl_elem_info *info) 485 { 486 struct snd_oxfw *oxfw = control->private_data; 487 488 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 489 info->count = oxfw->device_info->mixer_channels; 490 info->value.integer.min = oxfw->volume_min; 491 info->value.integer.max = oxfw->volume_max; 492 493 return 0; 494 } 495 496 static const u8 channel_map[6] = { 0, 1, 4, 5, 2, 3 }; 497 498 static int oxfw_volume_get(struct snd_kcontrol *control, 499 struct snd_ctl_elem_value *value) 500 { 501 struct snd_oxfw *oxfw = control->private_data; 502 unsigned int i; 503 504 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) 505 value->value.integer.value[channel_map[i]] = oxfw->volume[i]; 506 507 return 0; 508 } 509 510 static int oxfw_volume_put(struct snd_kcontrol *control, 511 struct snd_ctl_elem_value *value) 512 { 513 struct snd_oxfw *oxfw = control->private_data; 514 unsigned int i, changed_channels; 515 bool equal_values = true; 516 s16 volume; 517 int err; 518 519 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) { 520 if (value->value.integer.value[i] < oxfw->volume_min || 521 value->value.integer.value[i] > oxfw->volume_max) 522 return -EINVAL; 523 if (value->value.integer.value[i] != 524 value->value.integer.value[0]) 525 equal_values = false; 526 } 527 528 changed_channels = 0; 529 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) 530 if (value->value.integer.value[channel_map[i]] != 531 oxfw->volume[i]) 532 changed_channels |= 1 << (i + 1); 533 534 if (equal_values && changed_channels != 0) 535 changed_channels = 1 << 0; 536 537 for (i = 0; i <= oxfw->device_info->mixer_channels; ++i) { 538 volume = value->value.integer.value[channel_map[i ? i - 1 : 0]]; 539 if (changed_channels & (1 << i)) { 540 err = oxfw_volume_command(oxfw, &volume, i, 541 CTL_CURRENT, CTL_WRITE); 542 if (err < 0) 543 return err; 544 } 545 if (i > 0) 546 oxfw->volume[i - 1] = volume; 547 } 548 549 return changed_channels != 0; 550 } 551 552 static int oxfw_create_mixer(struct snd_oxfw *oxfw) 553 { 554 static const struct snd_kcontrol_new controls[] = { 555 { 556 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 557 .name = "PCM Playback Switch", 558 .info = snd_ctl_boolean_mono_info, 559 .get = oxfw_mute_get, 560 .put = oxfw_mute_put, 561 }, 562 { 563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 564 .name = "PCM Playback Volume", 565 .info = oxfw_volume_info, 566 .get = oxfw_volume_get, 567 .put = oxfw_volume_put, 568 }, 569 }; 570 unsigned int i, first_ch; 571 int err; 572 573 err = oxfw_volume_command(oxfw, &oxfw->volume_min, 574 0, CTL_MIN, CTL_READ); 575 if (err < 0) 576 return err; 577 err = oxfw_volume_command(oxfw, &oxfw->volume_max, 578 0, CTL_MAX, CTL_READ); 579 if (err < 0) 580 return err; 581 582 err = oxfw_mute_command(oxfw, &oxfw->mute, CTL_READ); 583 if (err < 0) 584 return err; 585 586 first_ch = oxfw->device_info->mixer_channels == 1 ? 0 : 1; 587 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) { 588 err = oxfw_volume_command(oxfw, &oxfw->volume[i], 589 first_ch + i, CTL_CURRENT, CTL_READ); 590 if (err < 0) 591 return err; 592 } 593 594 for (i = 0; i < ARRAY_SIZE(controls); ++i) { 595 err = snd_ctl_add(oxfw->card, 596 snd_ctl_new1(&controls[i], oxfw)); 597 if (err < 0) 598 return err; 599 } 600 601 return 0; 602 } 603 604 static u32 oxfw_read_firmware_version(struct fw_unit *unit) 605 { 606 __be32 data; 607 int err; 608 609 err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, 610 OXFORD_FIRMWARE_ID_ADDRESS, &data, 4, 0); 611 return err >= 0 ? be32_to_cpu(data) : 0; 612 } 613 614 static void oxfw_card_free(struct snd_card *card) 615 { 616 struct snd_oxfw *oxfw = card->private_data; 617 618 amdtp_stream_destroy(&oxfw->rx_stream); 619 cmp_connection_destroy(&oxfw->in_conn); 620 fw_unit_put(oxfw->unit); 621 mutex_destroy(&oxfw->mutex); 622 } 623 624 static int oxfw_probe(struct fw_unit *unit, 625 const struct ieee1394_device_id *id) 626 { 627 struct fw_device *fw_dev = fw_parent_device(unit); 628 struct snd_card *card; 629 struct snd_oxfw *oxfw; 630 u32 firmware; 631 int err; 632 633 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, 634 sizeof(*oxfw), &card); 635 if (err < 0) 636 return err; 637 638 oxfw = card->private_data; 639 oxfw->card = card; 640 mutex_init(&oxfw->mutex); 641 oxfw->unit = fw_unit_get(unit); 642 oxfw->device_info = (const struct device_info *)id->driver_data; 643 644 err = cmp_connection_init(&oxfw->in_conn, unit, CMP_INPUT, 0); 645 if (err < 0) 646 goto err_unit; 647 648 err = amdtp_stream_init(&oxfw->rx_stream, unit, AMDTP_OUT_STREAM, 649 CIP_NONBLOCKING); 650 if (err < 0) 651 goto err_connection; 652 653 card->private_free = oxfw_card_free; 654 655 strcpy(card->driver, oxfw->device_info->driver_name); 656 strcpy(card->shortname, oxfw->device_info->short_name); 657 firmware = oxfw_read_firmware_version(unit); 658 snprintf(card->longname, sizeof(card->longname), 659 "%s (OXFW%x %04x), GUID %08x%08x at %s, S%d", 660 oxfw->device_info->long_name, 661 firmware >> 20, firmware & 0xffff, 662 fw_dev->config_rom[3], fw_dev->config_rom[4], 663 dev_name(&unit->device), 100 << fw_dev->max_speed); 664 strcpy(card->mixername, "OXFW"); 665 666 err = oxfw_create_pcm(oxfw); 667 if (err < 0) 668 goto error; 669 670 err = oxfw_create_mixer(oxfw); 671 if (err < 0) 672 goto error; 673 674 err = snd_card_register(card); 675 if (err < 0) 676 goto error; 677 678 dev_set_drvdata(&unit->device, oxfw); 679 680 return 0; 681 682 err_connection: 683 cmp_connection_destroy(&oxfw->in_conn); 684 err_unit: 685 fw_unit_put(oxfw->unit); 686 mutex_destroy(&oxfw->mutex); 687 error: 688 snd_card_free(card); 689 return err; 690 } 691 692 static void oxfw_bus_reset(struct fw_unit *unit) 693 { 694 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device); 695 696 fcp_bus_reset(oxfw->unit); 697 698 if (cmp_connection_update(&oxfw->in_conn) < 0) { 699 amdtp_stream_pcm_abort(&oxfw->rx_stream); 700 mutex_lock(&oxfw->mutex); 701 oxfw_stop_stream(oxfw); 702 mutex_unlock(&oxfw->mutex); 703 return; 704 } 705 706 amdtp_stream_update(&oxfw->rx_stream); 707 } 708 709 static void oxfw_remove(struct fw_unit *unit) 710 { 711 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device); 712 713 amdtp_stream_pcm_abort(&oxfw->rx_stream); 714 snd_card_disconnect(oxfw->card); 715 716 mutex_lock(&oxfw->mutex); 717 oxfw_stop_stream(oxfw); 718 mutex_unlock(&oxfw->mutex); 719 720 snd_card_free_when_closed(oxfw->card); 721 } 722 723 static const struct device_info griffin_firewave = { 724 .driver_name = "FireWave", 725 .short_name = "FireWave", 726 .long_name = "Griffin FireWave Surround", 727 .pcm_constraints = firewave_constraints, 728 .mixer_channels = 6, 729 .mute_fb_id = 0x01, 730 .volume_fb_id = 0x02, 731 }; 732 733 static const struct device_info lacie_speakers = { 734 .driver_name = "FWSpeakers", 735 .short_name = "FireWire Speakers", 736 .long_name = "LaCie FireWire Speakers", 737 .pcm_constraints = lacie_speakers_constraints, 738 .mixer_channels = 1, 739 .mute_fb_id = 0x01, 740 .volume_fb_id = 0x01, 741 }; 742 743 static const struct ieee1394_device_id oxfw_id_table[] = { 744 { 745 .match_flags = IEEE1394_MATCH_VENDOR_ID | 746 IEEE1394_MATCH_MODEL_ID | 747 IEEE1394_MATCH_SPECIFIER_ID | 748 IEEE1394_MATCH_VERSION, 749 .vendor_id = VENDOR_GRIFFIN, 750 .model_id = 0x00f970, 751 .specifier_id = SPECIFIER_1394TA, 752 .version = VERSION_AVC, 753 .driver_data = (kernel_ulong_t)&griffin_firewave, 754 }, 755 { 756 .match_flags = IEEE1394_MATCH_VENDOR_ID | 757 IEEE1394_MATCH_MODEL_ID | 758 IEEE1394_MATCH_SPECIFIER_ID | 759 IEEE1394_MATCH_VERSION, 760 .vendor_id = VENDOR_LACIE, 761 .model_id = 0x00f970, 762 .specifier_id = SPECIFIER_1394TA, 763 .version = VERSION_AVC, 764 .driver_data = (kernel_ulong_t)&lacie_speakers, 765 }, 766 { } 767 }; 768 MODULE_DEVICE_TABLE(ieee1394, oxfw_id_table); 769 770 static struct fw_driver oxfw_driver = { 771 .driver = { 772 .owner = THIS_MODULE, 773 .name = KBUILD_MODNAME, 774 .bus = &fw_bus_type, 775 }, 776 .probe = oxfw_probe, 777 .update = oxfw_bus_reset, 778 .remove = oxfw_remove, 779 .id_table = oxfw_id_table, 780 }; 781 782 static int __init snd_oxfw_init(void) 783 { 784 return driver_register(&oxfw_driver.driver); 785 } 786 787 static void __exit snd_oxfw_exit(void) 788 { 789 driver_unregister(&oxfw_driver.driver); 790 } 791 792 module_init(snd_oxfw_init); 793 module_exit(snd_oxfw_exit); 794