1 // SPDX-License-Identifier: GPL-2.0-only
3 * ff.c - a part of driver for RME Fireface series
5 * Copyright (c) 2015-2017 Takashi Sakamoto
10 #define OUI_RME 0x000a35
12 MODULE_DESCRIPTION("RME Fireface series Driver");
13 MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
14 MODULE_LICENSE("GPL v2");
16 static void name_card(struct snd_ff *ff)
18 struct fw_device *fw_dev = fw_parent_device(ff->unit);
19 const char *const names[] = {
20 [SND_FF_UNIT_VERSION_FF800] = "Fireface800",
21 [SND_FF_UNIT_VERSION_FF400] = "Fireface400",
22 [SND_FF_UNIT_VERSION_UFX] = "FirefaceUFX",
23 [SND_FF_UNIT_VERSION_UCX] = "FirefaceUCX",
24 [SND_FF_UNIT_VERSION_802] = "Fireface802",
28 name = names[ff->unit_version];
30 strcpy(ff->card->driver, "Fireface");
31 strcpy(ff->card->shortname, name);
32 strcpy(ff->card->mixername, name);
33 snprintf(ff->card->longname, sizeof(ff->card->longname),
34 "RME %s, GUID %08x%08x at %s, S%d", name,
35 fw_dev->config_rom[3], fw_dev->config_rom[4],
36 dev_name(&ff->unit->device), 100 << fw_dev->max_speed);
39 static void ff_card_free(struct snd_card *card)
41 struct snd_ff *ff = card->private_data;
43 snd_ff_stream_destroy_duplex(ff);
44 snd_ff_transaction_unregister(ff);
46 mutex_destroy(&ff->mutex);
47 fw_unit_put(ff->unit);
50 static int snd_ff_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry)
52 struct snd_card *card;
56 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*ff), &card);
59 card->private_free = ff_card_free;
61 ff = card->private_data;
62 ff->unit = fw_unit_get(unit);
63 dev_set_drvdata(&unit->device, ff);
66 mutex_init(&ff->mutex);
67 spin_lock_init(&ff->lock);
68 init_waitqueue_head(&ff->hwdep_wait);
70 ff->unit_version = entry->version;
71 ff->spec = (const struct snd_ff_spec *)entry->driver_data;
73 err = snd_ff_transaction_register(ff);
79 err = snd_ff_stream_init_duplex(ff);
85 err = snd_ff_create_midi_devices(ff);
89 err = snd_ff_create_pcm_devices(ff);
93 err = snd_ff_create_hwdep_devices(ff);
97 err = snd_card_register(card);
107 static void snd_ff_update(struct fw_unit *unit)
109 struct snd_ff *ff = dev_get_drvdata(&unit->device);
111 snd_ff_transaction_reregister(ff);
113 snd_ff_stream_update_duplex(ff);
116 static void snd_ff_remove(struct fw_unit *unit)
118 struct snd_ff *ff = dev_get_drvdata(&unit->device);
120 // Block till all of ALSA character devices are released.
121 snd_card_free(ff->card);
124 static const struct snd_ff_spec spec_ff800 = {
125 .pcm_capture_channels = {28, 20, 12},
126 .pcm_playback_channels = {28, 20, 12},
129 .protocol = &snd_ff_protocol_ff800,
130 .midi_high_addr = 0x000200000320ull,
131 .midi_addr_range = 12,
132 .midi_rx_addrs = {0x000080180000ull, 0},
135 static const struct snd_ff_spec spec_ff400 = {
136 .pcm_capture_channels = {18, 14, 10},
137 .pcm_playback_channels = {18, 14, 10},
140 .protocol = &snd_ff_protocol_ff400,
141 .midi_high_addr = 0x0000801003f4ull,
142 .midi_addr_range = SND_FF_MAXIMIM_MIDI_QUADS * 4,
143 .midi_rx_addrs = {0x000080180000ull, 0x000080190000ull},
146 static const struct snd_ff_spec spec_ucx = {
147 .pcm_capture_channels = {18, 14, 12},
148 .pcm_playback_channels = {18, 14, 12},
151 .protocol = &snd_ff_protocol_latter,
152 .midi_high_addr = 0xffff00000034ull,
153 .midi_addr_range = 0x80,
154 .midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
157 static const struct snd_ff_spec spec_ufx_802 = {
158 .pcm_capture_channels = {30, 22, 14},
159 .pcm_playback_channels = {30, 22, 14},
162 .protocol = &snd_ff_protocol_latter,
163 .midi_high_addr = 0xffff00000034ull,
164 .midi_addr_range = 0x80,
165 .midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
168 static const struct ieee1394_device_id snd_ff_id_table[] = {
171 .match_flags = IEEE1394_MATCH_VENDOR_ID |
172 IEEE1394_MATCH_SPECIFIER_ID |
173 IEEE1394_MATCH_VERSION |
174 IEEE1394_MATCH_MODEL_ID,
175 .vendor_id = OUI_RME,
176 .specifier_id = OUI_RME,
177 .version = SND_FF_UNIT_VERSION_FF800,
178 .model_id = 0x101800,
179 .driver_data = (kernel_ulong_t)&spec_ff800,
183 .match_flags = IEEE1394_MATCH_VENDOR_ID |
184 IEEE1394_MATCH_SPECIFIER_ID |
185 IEEE1394_MATCH_VERSION |
186 IEEE1394_MATCH_MODEL_ID,
187 .vendor_id = OUI_RME,
188 .specifier_id = OUI_RME,
189 .version = SND_FF_UNIT_VERSION_FF400,
190 .model_id = 0x101800,
191 .driver_data = (kernel_ulong_t)&spec_ff400,
195 .match_flags = IEEE1394_MATCH_VENDOR_ID |
196 IEEE1394_MATCH_SPECIFIER_ID |
197 IEEE1394_MATCH_VERSION |
198 IEEE1394_MATCH_MODEL_ID,
199 .vendor_id = OUI_RME,
200 .specifier_id = OUI_RME,
201 .version = SND_FF_UNIT_VERSION_UFX,
202 .model_id = 0x101800,
203 .driver_data = (kernel_ulong_t)&spec_ufx_802,
207 .match_flags = IEEE1394_MATCH_VENDOR_ID |
208 IEEE1394_MATCH_SPECIFIER_ID |
209 IEEE1394_MATCH_VERSION |
210 IEEE1394_MATCH_MODEL_ID,
211 .vendor_id = OUI_RME,
212 .specifier_id = OUI_RME,
213 .version = SND_FF_UNIT_VERSION_UCX,
214 .model_id = 0x101800,
215 .driver_data = (kernel_ulong_t)&spec_ucx,
219 .match_flags = IEEE1394_MATCH_VENDOR_ID |
220 IEEE1394_MATCH_SPECIFIER_ID |
221 IEEE1394_MATCH_VERSION |
222 IEEE1394_MATCH_MODEL_ID,
223 .vendor_id = OUI_RME,
224 .specifier_id = OUI_RME,
225 .version = SND_FF_UNIT_VERSION_802,
226 .model_id = 0x101800,
227 .driver_data = (kernel_ulong_t)&spec_ufx_802,
231 MODULE_DEVICE_TABLE(ieee1394, snd_ff_id_table);
233 static struct fw_driver ff_driver = {
235 .owner = THIS_MODULE,
236 .name = KBUILD_MODNAME,
239 .probe = snd_ff_probe,
240 .update = snd_ff_update,
241 .remove = snd_ff_remove,
242 .id_table = snd_ff_id_table,
245 static int __init snd_ff_init(void)
247 return driver_register(&ff_driver.driver);
250 static void __exit snd_ff_exit(void)
252 driver_unregister(&ff_driver.driver);
255 module_init(snd_ff_init);
256 module_exit(snd_ff_exit);