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
21 #define VENDOR_TASCAM 0x00022e
22 #define OUI_STANTON 0x001260
24 #define MODEL_SATELLITE 0x00200f
26 #define SPECIFIER_1394TA 0x00a02d
27 #define VERSION_AVC 0x010001
29 MODULE_DESCRIPTION("Oxford Semiconductor FW970/971 driver");
30 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
31 MODULE_LICENSE("GPL v2");
32 MODULE_ALIAS("snd-firewire-speakers");
33 MODULE_ALIAS("snd-scs1x");
36 const char *driver_name
;
37 const char *vendor_name
;
38 const char *model_name
;
41 static bool detect_loud_models(struct fw_unit
*unit
)
43 const char *const models
[] = {
47 "Mackie Onyx Satellite",
48 "Tapco LINK.firewire 4x6",
54 err
= fw_csr_string(unit
->directory
, CSR_MODEL
,
55 model
, sizeof(model
));
59 for (i
= 0; i
< ARRAY_SIZE(models
); i
++) {
60 if (strcmp(models
[i
], model
) == 0)
64 return (i
< ARRAY_SIZE(models
));
67 static int name_card(struct snd_oxfw
*oxfw
)
69 struct fw_device
*fw_dev
= fw_parent_device(oxfw
->unit
);
70 const struct compat_info
*info
;
73 const char *d
, *v
, *m
;
77 /* get vendor name from root directory */
78 err
= fw_csr_string(fw_dev
->config_rom
+ 5, CSR_VENDOR
,
79 vendor
, sizeof(vendor
));
83 /* get model name from unit directory */
84 err
= fw_csr_string(oxfw
->unit
->directory
, CSR_MODEL
,
85 model
, sizeof(model
));
89 err
= snd_fw_transaction(oxfw
->unit
, TCODE_READ_QUADLET_REQUEST
,
90 OXFORD_FIRMWARE_ID_ADDRESS
, &firmware
, 4, 0);
93 be32_to_cpus(&firmware
);
95 /* to apply card definitions */
96 if (oxfw
->entry
->vendor_id
== VENDOR_GRIFFIN
||
97 oxfw
->entry
->vendor_id
== VENDOR_LACIE
) {
98 info
= (const struct compat_info
*)oxfw
->entry
->driver_data
;
99 d
= info
->driver_name
;
100 v
= info
->vendor_name
;
101 m
= info
->model_name
;
108 strcpy(oxfw
->card
->driver
, d
);
109 strcpy(oxfw
->card
->mixername
, m
);
110 strcpy(oxfw
->card
->shortname
, m
);
112 snprintf(oxfw
->card
->longname
, sizeof(oxfw
->card
->longname
),
113 "%s %s (OXFW%x %04x), GUID %08x%08x at %s, S%d",
114 v
, m
, firmware
>> 20, firmware
& 0xffff,
115 fw_dev
->config_rom
[3], fw_dev
->config_rom
[4],
116 dev_name(&oxfw
->unit
->device
), 100 << fw_dev
->max_speed
);
122 * This module releases the FireWire unit data after all ALSA character devices
123 * are released by applications. This is for releasing stream data or finishing
124 * transactions safely. Thus at returning from .remove(), this module still keep
125 * references for the unit.
127 static void oxfw_card_free(struct snd_card
*card
)
129 struct snd_oxfw
*oxfw
= card
->private_data
;
132 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
133 if (oxfw
->has_output
)
134 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
136 fw_unit_put(oxfw
->unit
);
138 for (i
= 0; i
< SND_OXFW_STREAM_FORMAT_ENTRIES
; i
++) {
139 kfree(oxfw
->tx_stream_formats
[i
]);
140 kfree(oxfw
->rx_stream_formats
[i
]);
144 mutex_destroy(&oxfw
->mutex
);
147 static int detect_quirks(struct snd_oxfw
*oxfw
)
149 struct fw_device
*fw_dev
= fw_parent_device(oxfw
->unit
);
150 struct fw_csr_iterator it
;
155 * Add ALSA control elements for two models to keep compatibility to
156 * old firewire-speaker module.
158 if (oxfw
->entry
->vendor_id
== VENDOR_GRIFFIN
)
159 return snd_oxfw_add_spkr(oxfw
, false);
160 if (oxfw
->entry
->vendor_id
== VENDOR_LACIE
)
161 return snd_oxfw_add_spkr(oxfw
, true);
164 * Stanton models supports asynchronous transactions for unique MIDI
167 if (oxfw
->entry
->vendor_id
== OUI_STANTON
) {
168 /* No physical MIDI ports. */
169 oxfw
->midi_input_ports
= 0;
170 oxfw
->midi_output_ports
= 0;
172 /* Output stream exists but no data channels are useful. */
173 oxfw
->has_output
= false;
175 return snd_oxfw_scs1x_add(oxfw
);
179 * TASCAM FireOne has physical control and requires a pair of additional
182 if (oxfw
->entry
->vendor_id
== VENDOR_TASCAM
) {
183 oxfw
->midi_input_ports
++;
184 oxfw
->midi_output_ports
++;
188 /* Seek from Root Directory of Config ROM. */
190 fw_csr_iterator_init(&it
, fw_dev
->config_rom
+ 5);
191 while (fw_csr_iterator_next(&it
, &key
, &val
)) {
192 if (key
== CSR_VENDOR
)
194 else if (key
== CSR_MODEL
)
199 * Mackie Onyx Satellite with base station has a quirk to report a wrong
200 * value in 'dbs' field of CIP header against its format information.
202 if (vendor
== VENDOR_LOUD
&& model
== MODEL_SATELLITE
)
203 oxfw
->wrong_dbs
= true;
208 static int oxfw_probe(struct fw_unit
*unit
,
209 const struct ieee1394_device_id
*entry
)
211 struct snd_card
*card
;
212 struct snd_oxfw
*oxfw
;
215 if (entry
->vendor_id
== VENDOR_LOUD
&& !detect_loud_models(unit
))
218 err
= snd_card_new(&unit
->device
, -1, NULL
, THIS_MODULE
,
219 sizeof(*oxfw
), &card
);
223 card
->private_free
= oxfw_card_free
;
224 oxfw
= card
->private_data
;
226 mutex_init(&oxfw
->mutex
);
227 oxfw
->unit
= fw_unit_get(unit
);
229 spin_lock_init(&oxfw
->lock
);
230 init_waitqueue_head(&oxfw
->hwdep_wait
);
232 err
= snd_oxfw_stream_discover(oxfw
);
236 err
= name_card(oxfw
);
240 err
= detect_quirks(oxfw
);
244 err
= snd_oxfw_create_pcm(oxfw
);
248 snd_oxfw_proc_init(oxfw
);
250 err
= snd_oxfw_create_midi(oxfw
);
254 err
= snd_oxfw_create_hwdep(oxfw
);
258 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->rx_stream
);
261 if (oxfw
->has_output
) {
262 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->tx_stream
);
267 err
= snd_card_register(card
);
269 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
270 if (oxfw
->has_output
)
271 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
274 dev_set_drvdata(&unit
->device
, oxfw
);
282 static void oxfw_bus_reset(struct fw_unit
*unit
)
284 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
286 fcp_bus_reset(oxfw
->unit
);
288 mutex_lock(&oxfw
->mutex
);
290 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->rx_stream
);
291 if (oxfw
->has_output
)
292 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->tx_stream
);
294 mutex_unlock(&oxfw
->mutex
);
296 if (oxfw
->entry
->vendor_id
== OUI_STANTON
)
297 snd_oxfw_scs1x_update(oxfw
);
300 static void oxfw_remove(struct fw_unit
*unit
)
302 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
304 /* No need to wait for releasing card object in this context. */
305 snd_card_free_when_closed(oxfw
->card
);
308 static const struct compat_info griffin_firewave
= {
309 .driver_name
= "FireWave",
310 .vendor_name
= "Griffin",
311 .model_name
= "FireWave",
314 static const struct compat_info lacie_speakers
= {
315 .driver_name
= "FWSpeakers",
316 .vendor_name
= "LaCie",
317 .model_name
= "FireWire Speakers",
320 static const struct ieee1394_device_id oxfw_id_table
[] = {
322 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
323 IEEE1394_MATCH_MODEL_ID
|
324 IEEE1394_MATCH_SPECIFIER_ID
|
325 IEEE1394_MATCH_VERSION
,
326 .vendor_id
= VENDOR_GRIFFIN
,
327 .model_id
= 0x00f970,
328 .specifier_id
= SPECIFIER_1394TA
,
329 .version
= VERSION_AVC
,
330 .driver_data
= (kernel_ulong_t
)&griffin_firewave
,
333 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
334 IEEE1394_MATCH_MODEL_ID
|
335 IEEE1394_MATCH_SPECIFIER_ID
|
336 IEEE1394_MATCH_VERSION
,
337 .vendor_id
= VENDOR_LACIE
,
338 .model_id
= 0x00f970,
339 .specifier_id
= SPECIFIER_1394TA
,
340 .version
= VERSION_AVC
,
341 .driver_data
= (kernel_ulong_t
)&lacie_speakers
,
343 /* Behringer,F-Control Audio 202 */
345 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
346 IEEE1394_MATCH_MODEL_ID
,
347 .vendor_id
= VENDOR_BEHRINGER
,
348 .model_id
= 0x00fc22,
351 * Any Mackie(Loud) models (name string/model id):
352 * Onyx-i series (former models): 0x081216
353 * Mackie Onyx Satellite: 0x00200f
354 * Tapco LINK.firewire 4x6: 0x000460
361 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
362 IEEE1394_MATCH_SPECIFIER_ID
|
363 IEEE1394_MATCH_VERSION
,
364 .vendor_id
= VENDOR_LOUD
,
365 .specifier_id
= SPECIFIER_1394TA
,
366 .version
= VERSION_AVC
,
368 /* TASCAM, FireOne */
370 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
371 IEEE1394_MATCH_MODEL_ID
,
372 .vendor_id
= VENDOR_TASCAM
,
373 .model_id
= 0x800007,
375 /* Stanton, Stanton Controllers & Systems 1 Mixer (SCS.1m) */
377 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
378 IEEE1394_MATCH_MODEL_ID
,
379 .vendor_id
= OUI_STANTON
,
380 .model_id
= 0x001000,
382 /* Stanton, Stanton Controllers & Systems 1 Deck (SCS.1d) */
384 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
385 IEEE1394_MATCH_MODEL_ID
,
386 .vendor_id
= OUI_STANTON
,
387 .model_id
= 0x002000,
391 MODULE_DEVICE_TABLE(ieee1394
, oxfw_id_table
);
393 static struct fw_driver oxfw_driver
= {
395 .owner
= THIS_MODULE
,
396 .name
= KBUILD_MODNAME
,
400 .update
= oxfw_bus_reset
,
401 .remove
= oxfw_remove
,
402 .id_table
= oxfw_id_table
,
405 static int __init
snd_oxfw_init(void)
407 return driver_register(&oxfw_driver
.driver
);
410 static void __exit
snd_oxfw_exit(void)
412 driver_unregister(&oxfw_driver
.driver
);
415 module_init(snd_oxfw_init
);
416 module_exit(snd_oxfw_exit
);