1 // SPDX-License-Identifier: GPL-2.0-only
3 * tascam.c - a part of driver for TASCAM FireWire series
5 * Copyright (c) 2015 Takashi Sakamoto
10 MODULE_DESCRIPTION("TASCAM FireWire series Driver");
11 MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
12 MODULE_LICENSE("GPL v2");
14 static const struct snd_tscm_spec model_specs[] = {
19 .pcm_capture_analog_channels = 8,
20 .pcm_playback_analog_channels = 8,
21 .midi_capture_ports = 4,
22 .midi_playback_ports = 4,
28 .pcm_capture_analog_channels = 8,
29 .pcm_playback_analog_channels = 2,
30 .midi_capture_ports = 2,
31 .midi_playback_ports = 2,
37 .pcm_capture_analog_channels = 8,
38 .pcm_playback_analog_channels = 2,
39 .midi_capture_ports = 2,
40 .midi_playback_ports = 4,
44 static int identify_model(struct snd_tscm *tscm)
46 struct fw_device *fw_dev = fw_parent_device(tscm->unit);
47 const u32 *config_rom = fw_dev->config_rom;
52 if (fw_dev->config_rom_length < 30) {
53 dev_err(&tscm->unit->device,
54 "Configuration ROM is too short.\n");
58 /* Pick up model name from certain addresses. */
59 for (i = 0; i < 8; i++) {
60 c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
67 for (i = 0; i < ARRAY_SIZE(model_specs); i++) {
68 if (strcmp(model, model_specs[i].name) == 0) {
69 tscm->spec = &model_specs[i];
73 if (tscm->spec == NULL)
76 strcpy(tscm->card->driver, "FW-TASCAM");
77 strcpy(tscm->card->shortname, model);
78 strcpy(tscm->card->mixername, model);
79 snprintf(tscm->card->longname, sizeof(tscm->card->longname),
80 "TASCAM %s, GUID %08x%08x at %s, S%d", model,
81 fw_dev->config_rom[3], fw_dev->config_rom[4],
82 dev_name(&tscm->unit->device), 100 << fw_dev->max_speed);
87 static void tscm_card_free(struct snd_card *card)
89 struct snd_tscm *tscm = card->private_data;
91 snd_tscm_transaction_unregister(tscm);
92 snd_tscm_stream_destroy_duplex(tscm);
94 mutex_destroy(&tscm->mutex);
95 fw_unit_put(tscm->unit);
98 static int snd_tscm_probe(struct fw_unit *unit,
99 const struct ieee1394_device_id *entry)
101 struct snd_card *card;
102 struct snd_tscm *tscm;
105 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*tscm), &card);
108 card->private_free = tscm_card_free;
110 tscm = card->private_data;
111 tscm->unit = fw_unit_get(unit);
112 dev_set_drvdata(&unit->device, tscm);
115 mutex_init(&tscm->mutex);
116 spin_lock_init(&tscm->lock);
117 init_waitqueue_head(&tscm->hwdep_wait);
119 err = identify_model(tscm);
123 err = snd_tscm_transaction_register(tscm);
127 err = snd_tscm_stream_init_duplex(tscm);
131 snd_tscm_proc_init(tscm);
133 err = snd_tscm_create_pcm_devices(tscm);
137 err = snd_tscm_create_midi_devices(tscm);
141 err = snd_tscm_create_hwdep_device(tscm);
145 err = snd_card_register(card);
155 static void snd_tscm_update(struct fw_unit *unit)
157 struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
159 snd_tscm_transaction_reregister(tscm);
161 mutex_lock(&tscm->mutex);
162 snd_tscm_stream_update_duplex(tscm);
163 mutex_unlock(&tscm->mutex);
166 static void snd_tscm_remove(struct fw_unit *unit)
168 struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
170 // Block till all of ALSA character devices are released.
171 snd_card_free(tscm->card);
174 static const struct ieee1394_device_id snd_tscm_id_table[] = {
177 .match_flags = IEEE1394_MATCH_VENDOR_ID |
178 IEEE1394_MATCH_SPECIFIER_ID |
179 IEEE1394_MATCH_VERSION,
180 .vendor_id = 0x00022e,
181 .specifier_id = 0x00022e,
184 // Tascam, FE-8 (.version = 0x800001)
185 // This kernel module doesn't support FE-8 because the most of features
186 // can be implemented in userspace without any specific support of this
189 // .version = 0x800002 is unknown.
193 .match_flags = IEEE1394_MATCH_VENDOR_ID |
194 IEEE1394_MATCH_SPECIFIER_ID |
195 IEEE1394_MATCH_VERSION,
196 .vendor_id = 0x00022e,
197 .specifier_id = 0x00022e,
202 .match_flags = IEEE1394_MATCH_VENDOR_ID |
203 IEEE1394_MATCH_SPECIFIER_ID |
204 IEEE1394_MATCH_VERSION,
205 .vendor_id = 0x00022e,
206 .specifier_id = 0x00022e,
211 MODULE_DEVICE_TABLE(ieee1394, snd_tscm_id_table);
213 static struct fw_driver tscm_driver = {
215 .owner = THIS_MODULE,
216 .name = KBUILD_MODNAME,
219 .probe = snd_tscm_probe,
220 .update = snd_tscm_update,
221 .remove = snd_tscm_remove,
222 .id_table = snd_tscm_id_table,
225 static int __init snd_tscm_init(void)
227 return driver_register(&tscm_driver.driver);
230 static void __exit snd_tscm_exit(void)
232 driver_unregister(&tscm_driver.driver);
235 module_init(snd_tscm_init);
236 module_exit(snd_tscm_exit);