2019-05-30 06:57:59 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2015-10-01 20:02:11 +07:00
|
|
|
/*
|
|
|
|
* tascam.c - a part of driver for TASCAM FireWire series
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Takashi Sakamoto
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tascam.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("TASCAM FireWire series Driver");
|
|
|
|
MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
|
2017-08-22 20:58:15 +07:00
|
|
|
static const struct snd_tscm_spec model_specs[] = {
|
2015-10-01 20:02:12 +07:00
|
|
|
{
|
|
|
|
.name = "FW-1884",
|
|
|
|
.has_adat = true,
|
|
|
|
.has_spdif = true,
|
|
|
|
.pcm_capture_analog_channels = 8,
|
|
|
|
.pcm_playback_analog_channels = 8,
|
|
|
|
.midi_capture_ports = 4,
|
|
|
|
.midi_playback_ports = 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "FW-1082",
|
|
|
|
.has_adat = false,
|
|
|
|
.has_spdif = true,
|
|
|
|
.pcm_capture_analog_channels = 8,
|
|
|
|
.pcm_playback_analog_channels = 2,
|
|
|
|
.midi_capture_ports = 2,
|
|
|
|
.midi_playback_ports = 2,
|
|
|
|
},
|
2016-02-05 07:56:06 +07:00
|
|
|
{
|
|
|
|
.name = "FW-1804",
|
|
|
|
.has_adat = true,
|
|
|
|
.has_spdif = true,
|
|
|
|
.pcm_capture_analog_channels = 8,
|
|
|
|
.pcm_playback_analog_channels = 2,
|
|
|
|
.midi_capture_ports = 2,
|
|
|
|
.midi_playback_ports = 4,
|
|
|
|
},
|
ALSA: firewire-tascam: add note for FE-8
TASCAM FE-8 is the rest of model in TASCAM FireWire series. This device
has no functionality to process audio signal and MIDI messages. Instead,
it transfers control messages to host system corresponding to operations
for some faders, buttons and knobs on its surface.
Unlike the other devices in this series, the control messages are
transmitted by asynchronous transactions. Some registers of device are
used for registration of destination address for the transaction. The
transaction includes quadlet-aligned data up to 32 quadlets.
Userspace applications can receive the transaction and parse it for
control message via Linux FireWire subsystem, without any support by
ALSA firewire-tascam driver. Therefore the driver gives no support
for it.
This commit removes placeholder for FE-8 and add some comment for its
functionalities as notes.
$ python2 linux-firewire-utils/src/crpp < ~/git/am-config-rom/tascam/tascam-fe8.img
ROM header and bus information block
-----------------------------------------------------------------
400 040f4798 bus_info_length 4, crc_length 15, crc 18328 (should be 14256)
404 31333934 bus_name "1394"
408 20ff7002 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 255, max_rec 7 (256)
40c 00022eff company_id 00022e |
410 a094dcb7 device_id ffa094dcb7 | EUI-64 00022effa094dcb7
root directory
-----------------------------------------------------------------
414 0004bccc directory_length 4, crc 48332
418 0300022e vendor
41c 0c0083c0 node capabilities per IEEE 1394
420 8d000006 --> eui-64 leaf at 438
424 d1000001 --> unit directory at 428
unit directory at 428
-----------------------------------------------------------------
428 0003eda4 directory_length 3, crc 60836
42c 1200022e specifier id
430 13800001 version
434 d4000004 --> dependent info directory at 444
eui-64 leaf at 438
-----------------------------------------------------------------
438 0002461e leaf_length 2, crc 17950
43c 00022eff company_id 00022e |
440 a094dcb7 device_id ffa094dcb7 | EUI-64 00022effa094dcb7
dependent info directory at 444
-----------------------------------------------------------------
444 0002ae47 directory_length 2, crc 44615
448 81000002 --> descriptor leaf at 450
44c 82000006 --> bus dependent info leaf at 464
descriptor leaf at 450
-----------------------------------------------------------------
450 0004a79e leaf_length 4, crc 42910
454 00000000 textual descriptor
458 00000000 minimal ASCII
45c 54415343 "TASC"
460 414d0000 "AM"
bus dependent info leaf at 464
-----------------------------------------------------------------
464 0004a7d8 leaf_length 4, crc 42968
468 00000000
46c 00000000
470 46452d38
474 00000000
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20190906125544.13800-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-09-06 19:55:44 +07:00
|
|
|
// This kernel module doesn't support FE-8 because the most of features
|
|
|
|
// can be implemented in userspace without any specific support of this
|
|
|
|
// module.
|
2015-10-01 20:02:12 +07:00
|
|
|
};
|
|
|
|
|
2015-10-12 17:10:25 +07:00
|
|
|
static int identify_model(struct snd_tscm *tscm)
|
2015-10-01 20:02:11 +07:00
|
|
|
{
|
|
|
|
struct fw_device *fw_dev = fw_parent_device(tscm->unit);
|
2015-10-12 17:10:25 +07:00
|
|
|
const u32 *config_rom = fw_dev->config_rom;
|
2015-10-19 18:29:27 +07:00
|
|
|
char model[9];
|
2015-10-12 17:10:25 +07:00
|
|
|
unsigned int i;
|
|
|
|
u8 c;
|
|
|
|
|
|
|
|
if (fw_dev->config_rom_length < 30) {
|
|
|
|
dev_err(&tscm->unit->device,
|
|
|
|
"Configuration ROM is too short.\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pick up model name from certain addresses. */
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
|
|
|
|
if (c == '\0')
|
|
|
|
break;
|
|
|
|
model[i] = c;
|
|
|
|
}
|
|
|
|
model[i] = '\0';
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(model_specs); i++) {
|
|
|
|
if (strcmp(model, model_specs[i].name) == 0) {
|
|
|
|
tscm->spec = &model_specs[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tscm->spec == NULL)
|
|
|
|
return -ENODEV;
|
2015-10-01 20:02:11 +07:00
|
|
|
|
|
|
|
strcpy(tscm->card->driver, "FW-TASCAM");
|
|
|
|
strcpy(tscm->card->shortname, model);
|
|
|
|
strcpy(tscm->card->mixername, model);
|
|
|
|
snprintf(tscm->card->longname, sizeof(tscm->card->longname),
|
2015-10-12 17:10:25 +07:00
|
|
|
"TASCAM %s, GUID %08x%08x at %s, S%d", model,
|
2015-10-18 20:39:53 +07:00
|
|
|
fw_dev->config_rom[3], fw_dev->config_rom[4],
|
2015-10-01 20:02:11 +07:00
|
|
|
dev_name(&tscm->unit->device), 100 << fw_dev->max_speed);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-10 13:35:02 +07:00
|
|
|
static void tscm_card_free(struct snd_card *card)
|
2015-10-01 20:02:11 +07:00
|
|
|
{
|
2018-10-10 13:35:02 +07:00
|
|
|
struct snd_tscm *tscm = card->private_data;
|
|
|
|
|
2015-10-12 17:10:21 +07:00
|
|
|
snd_tscm_transaction_unregister(tscm);
|
2015-10-01 20:02:15 +07:00
|
|
|
snd_tscm_stream_destroy_duplex(tscm);
|
2015-10-01 20:02:11 +07:00
|
|
|
}
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
static void do_registration(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct snd_tscm *tscm = container_of(work, struct snd_tscm, dwork.work);
|
2015-10-01 20:02:11 +07:00
|
|
|
int err;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
err = snd_card_new(&tscm->unit->device, -1, NULL, THIS_MODULE, 0,
|
|
|
|
&tscm->card);
|
2015-10-01 20:02:11 +07:00
|
|
|
if (err < 0)
|
2016-03-31 06:47:09 +07:00
|
|
|
return;
|
2018-10-10 13:35:02 +07:00
|
|
|
tscm->card->private_free = tscm_card_free;
|
|
|
|
tscm->card->private_data = tscm;
|
2015-10-01 20:02:11 +07:00
|
|
|
|
2015-10-12 17:10:25 +07:00
|
|
|
err = identify_model(tscm);
|
2015-10-01 20:02:11 +07:00
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
err = snd_tscm_transaction_register(tscm);
|
2015-10-01 20:02:15 +07:00
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
err = snd_tscm_stream_init_duplex(tscm);
|
2015-10-01 20:02:16 +07:00
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
snd_tscm_proc_init(tscm);
|
|
|
|
|
|
|
|
err = snd_tscm_create_pcm_devices(tscm);
|
2015-10-12 17:10:21 +07:00
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-12 17:10:23 +07:00
|
|
|
err = snd_tscm_create_midi_devices(tscm);
|
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-01 20:02:17 +07:00
|
|
|
err = snd_tscm_create_hwdep_device(tscm);
|
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
err = snd_card_register(tscm->card);
|
2015-10-01 20:02:11 +07:00
|
|
|
if (err < 0)
|
|
|
|
goto error;
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
tscm->registered = true;
|
2015-10-01 20:02:11 +07:00
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
return;
|
2015-10-01 20:02:11 +07:00
|
|
|
error:
|
2016-03-31 06:47:09 +07:00
|
|
|
snd_card_free(tscm->card);
|
|
|
|
dev_info(&tscm->unit->device,
|
|
|
|
"Sound card registration failed: %d\n", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_tscm_probe(struct fw_unit *unit,
|
|
|
|
const struct ieee1394_device_id *entry)
|
|
|
|
{
|
|
|
|
struct snd_tscm *tscm;
|
|
|
|
|
|
|
|
/* Allocate this independent of sound card instance. */
|
2018-10-03 06:21:50 +07:00
|
|
|
tscm = devm_kzalloc(&unit->device, sizeof(struct snd_tscm), GFP_KERNEL);
|
|
|
|
if (!tscm)
|
2016-03-31 06:47:09 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
tscm->unit = fw_unit_get(unit);
|
|
|
|
dev_set_drvdata(&unit->device, tscm);
|
|
|
|
|
|
|
|
mutex_init(&tscm->mutex);
|
|
|
|
spin_lock_init(&tscm->lock);
|
|
|
|
init_waitqueue_head(&tscm->hwdep_wait);
|
|
|
|
|
|
|
|
/* Allocate and register this sound card later. */
|
|
|
|
INIT_DEFERRABLE_WORK(&tscm->dwork, do_registration);
|
|
|
|
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
|
|
|
|
|
|
return 0;
|
2015-10-01 20:02:11 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_tscm_update(struct fw_unit *unit)
|
|
|
|
{
|
2015-10-01 20:02:15 +07:00
|
|
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
/* Postpone a workqueue for deferred registration. */
|
|
|
|
if (!tscm->registered)
|
|
|
|
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
|
|
|
2015-10-12 17:10:21 +07:00
|
|
|
snd_tscm_transaction_reregister(tscm);
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
/*
|
|
|
|
* After registration, userspace can start packet streaming, then this
|
|
|
|
* code block works fine.
|
|
|
|
*/
|
|
|
|
if (tscm->registered) {
|
|
|
|
mutex_lock(&tscm->mutex);
|
|
|
|
snd_tscm_stream_update_duplex(tscm);
|
|
|
|
mutex_unlock(&tscm->mutex);
|
|
|
|
}
|
2015-10-01 20:02:11 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_tscm_remove(struct fw_unit *unit)
|
|
|
|
{
|
|
|
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
|
|
|
|
2016-03-31 06:47:09 +07:00
|
|
|
/*
|
|
|
|
* Confirm to stop the work for registration before the sound card is
|
|
|
|
* going to be released. The work is not scheduled again because bus
|
|
|
|
* reset handler is not called anymore.
|
|
|
|
*/
|
|
|
|
cancel_delayed_work_sync(&tscm->dwork);
|
|
|
|
|
|
|
|
if (tscm->registered) {
|
2018-10-10 13:34:59 +07:00
|
|
|
// Block till all of ALSA character devices are released.
|
|
|
|
snd_card_free(tscm->card);
|
2016-03-31 06:47:09 +07:00
|
|
|
}
|
2018-10-10 13:35:00 +07:00
|
|
|
|
|
|
|
mutex_destroy(&tscm->mutex);
|
|
|
|
fw_unit_put(tscm->unit);
|
2015-10-01 20:02:11 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ieee1394_device_id snd_tscm_id_table[] = {
|
|
|
|
{
|
|
|
|
.match_flags = IEEE1394_MATCH_VENDOR_ID |
|
2015-10-12 17:10:25 +07:00
|
|
|
IEEE1394_MATCH_SPECIFIER_ID,
|
2015-10-01 20:02:11 +07:00
|
|
|
.vendor_id = 0x00022e,
|
|
|
|
.specifier_id = 0x00022e,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(ieee1394, snd_tscm_id_table);
|
|
|
|
|
|
|
|
static struct fw_driver tscm_driver = {
|
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "snd-firewire-tascam",
|
|
|
|
.bus = &fw_bus_type,
|
|
|
|
},
|
|
|
|
.probe = snd_tscm_probe,
|
|
|
|
.update = snd_tscm_update,
|
|
|
|
.remove = snd_tscm_remove,
|
|
|
|
.id_table = snd_tscm_id_table,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init snd_tscm_init(void)
|
|
|
|
{
|
|
|
|
return driver_register(&tscm_driver.driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit snd_tscm_exit(void)
|
|
|
|
{
|
|
|
|
driver_unregister(&tscm_driver.driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(snd_tscm_init);
|
|
|
|
module_exit(snd_tscm_exit);
|