2 * oxfw.c - a part of driver for OXFW970/971 based devices
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2.
10 #define OXFORD_FIRMWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x50000)
11 /* 0x970?vvvv or 0x971?vvvv, where vvvv = firmware version */
13 #define OXFORD_HARDWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x90020)
14 #define OXFORD_HARDWARE_ID_OXFW970 0x39443841
15 #define OXFORD_HARDWARE_ID_OXFW971 0x39373100
17 #define VENDOR_LOUD 0x000ff2
18 #define VENDOR_GRIFFIN 0x001292
19 #define VENDOR_BEHRINGER 0x001564
20 #define VENDOR_LACIE 0x00d04b
22 #define SPECIFIER_1394TA 0x00a02d
23 #define VERSION_AVC 0x010001
25 MODULE_DESCRIPTION("Oxford Semiconductor FW970/971 driver");
26 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
27 MODULE_LICENSE("GPL v2");
28 MODULE_ALIAS("snd-firewire-speakers");
30 static bool detect_loud_models(struct fw_unit *unit)
32 const char *const models[] = {
36 "Mackie Onyx Satellite",
37 "Tapco LINK.firewire 4x6",
43 err = fw_csr_string(unit->directory, CSR_MODEL,
44 model, sizeof(model));
48 for (i = 0; i < ARRAY_SIZE(models); i++) {
49 if (strcmp(models[i], model) == 0)
53 return (i < ARRAY_SIZE(models));
56 static int name_card(struct snd_oxfw *oxfw)
58 struct fw_device *fw_dev = fw_parent_device(oxfw->unit);
61 const char *d, *v, *m;
65 /* get vendor name from root directory */
66 err = fw_csr_string(fw_dev->config_rom + 5, CSR_VENDOR,
67 vendor, sizeof(vendor));
71 /* get model name from unit directory */
72 err = fw_csr_string(oxfw->unit->directory, CSR_MODEL,
73 model, sizeof(model));
77 err = snd_fw_transaction(oxfw->unit, TCODE_READ_QUADLET_REQUEST,
78 OXFORD_FIRMWARE_ID_ADDRESS, &firmware, 4, 0);
81 be32_to_cpus(&firmware);
83 /* to apply card definitions */
84 if (oxfw->device_info) {
85 d = oxfw->device_info->driver_name;
86 v = oxfw->device_info->vendor_name;
87 m = oxfw->device_info->model_name;
94 strcpy(oxfw->card->driver, d);
95 strcpy(oxfw->card->mixername, m);
96 strcpy(oxfw->card->shortname, m);
98 snprintf(oxfw->card->longname, sizeof(oxfw->card->longname),
99 "%s %s (OXFW%x %04x), GUID %08x%08x at %s, S%d",
100 v, m, firmware >> 20, firmware & 0xffff,
101 fw_dev->config_rom[3], fw_dev->config_rom[4],
102 dev_name(&oxfw->unit->device), 100 << fw_dev->max_speed);
107 static void oxfw_card_free(struct snd_card *card)
109 struct snd_oxfw *oxfw = card->private_data;
112 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
113 kfree(oxfw->tx_stream_formats[i]);
114 kfree(oxfw->rx_stream_formats[i]);
117 mutex_destroy(&oxfw->mutex);
120 static int oxfw_probe(struct fw_unit *unit,
121 const struct ieee1394_device_id *id)
123 struct snd_card *card;
124 struct snd_oxfw *oxfw;
127 if ((id->vendor_id == VENDOR_LOUD) && !detect_loud_models(unit))
130 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
131 sizeof(*oxfw), &card);
135 card->private_free = oxfw_card_free;
136 oxfw = card->private_data;
138 mutex_init(&oxfw->mutex);
140 oxfw->device_info = (const struct device_info *)id->driver_data;
141 spin_lock_init(&oxfw->lock);
142 init_waitqueue_head(&oxfw->hwdep_wait);
144 err = snd_oxfw_stream_discover(oxfw);
148 err = name_card(oxfw);
152 err = snd_oxfw_create_pcm(oxfw);
156 if (oxfw->device_info) {
157 err = snd_oxfw_create_mixer(oxfw);
162 snd_oxfw_proc_init(oxfw);
164 err = snd_oxfw_create_midi(oxfw);
168 err = snd_oxfw_create_hwdep(oxfw);
172 err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->rx_stream);
175 if (oxfw->has_output) {
176 err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->tx_stream);
181 err = snd_card_register(card);
183 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
184 if (oxfw->has_output)
185 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
188 dev_set_drvdata(&unit->device, oxfw);
196 static void oxfw_bus_reset(struct fw_unit *unit)
198 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);
200 fcp_bus_reset(oxfw->unit);
202 mutex_lock(&oxfw->mutex);
204 snd_oxfw_stream_update_simplex(oxfw, &oxfw->rx_stream);
205 if (oxfw->has_output)
206 snd_oxfw_stream_update_simplex(oxfw, &oxfw->tx_stream);
208 mutex_unlock(&oxfw->mutex);
211 static void oxfw_remove(struct fw_unit *unit)
213 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);
215 snd_card_disconnect(oxfw->card);
217 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
218 if (oxfw->has_output)
219 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
221 snd_card_free_when_closed(oxfw->card);
224 static const struct device_info griffin_firewave = {
225 .driver_name = "FireWave",
226 .vendor_name = "Griffin",
227 .model_name = "FireWave",
230 .volume_fb_id = 0x02,
233 static const struct device_info lacie_speakers = {
234 .driver_name = "FWSpeakers",
235 .vendor_name = "LaCie",
236 .model_name = "FireWire Speakers",
239 .volume_fb_id = 0x01,
242 static const struct ieee1394_device_id oxfw_id_table[] = {
244 .match_flags = IEEE1394_MATCH_VENDOR_ID |
245 IEEE1394_MATCH_MODEL_ID |
246 IEEE1394_MATCH_SPECIFIER_ID |
247 IEEE1394_MATCH_VERSION,
248 .vendor_id = VENDOR_GRIFFIN,
249 .model_id = 0x00f970,
250 .specifier_id = SPECIFIER_1394TA,
251 .version = VERSION_AVC,
252 .driver_data = (kernel_ulong_t)&griffin_firewave,
255 .match_flags = IEEE1394_MATCH_VENDOR_ID |
256 IEEE1394_MATCH_MODEL_ID |
257 IEEE1394_MATCH_SPECIFIER_ID |
258 IEEE1394_MATCH_VERSION,
259 .vendor_id = VENDOR_LACIE,
260 .model_id = 0x00f970,
261 .specifier_id = SPECIFIER_1394TA,
262 .version = VERSION_AVC,
263 .driver_data = (kernel_ulong_t)&lacie_speakers,
265 /* Behringer,F-Control Audio 202 */
267 .match_flags = IEEE1394_MATCH_VENDOR_ID |
268 IEEE1394_MATCH_MODEL_ID,
269 .vendor_id = VENDOR_BEHRINGER,
270 .model_id = 0x00fc22,
273 * Any Mackie(Loud) models (name string/model id):
274 * Onyx-i series (former models): 0x081216
275 * Mackie Onyx Satellite: 0x00200f
276 * Tapco LINK.firewire 4x6: 0x000460
283 .match_flags = IEEE1394_MATCH_VENDOR_ID |
284 IEEE1394_MATCH_SPECIFIER_ID |
285 IEEE1394_MATCH_VERSION,
286 .vendor_id = VENDOR_LOUD,
287 .specifier_id = SPECIFIER_1394TA,
288 .version = VERSION_AVC,
292 MODULE_DEVICE_TABLE(ieee1394, oxfw_id_table);
294 static struct fw_driver oxfw_driver = {
296 .owner = THIS_MODULE,
297 .name = KBUILD_MODNAME,
301 .update = oxfw_bus_reset,
302 .remove = oxfw_remove,
303 .id_table = oxfw_id_table,
306 static int __init snd_oxfw_init(void)
308 return driver_register(&oxfw_driver.driver);
311 static void __exit snd_oxfw_exit(void)
313 driver_unregister(&oxfw_driver.driver);
316 module_init(snd_oxfw_init);
317 module_exit(snd_oxfw_exit);