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
23 #define MODEL_SATELLITE 0x00200f
25 #define SPECIFIER_1394TA 0x00a02d
26 #define VERSION_AVC 0x010001
28 MODULE_DESCRIPTION("Oxford Semiconductor FW970/971 driver");
29 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
30 MODULE_LICENSE("GPL v2");
31 MODULE_ALIAS("snd-firewire-speakers");
33 static bool detect_loud_models(struct fw_unit
*unit
)
35 const char *const models
[] = {
39 "Mackie Onyx Satellite",
40 "Tapco LINK.firewire 4x6",
46 err
= fw_csr_string(unit
->directory
, CSR_MODEL
,
47 model
, sizeof(model
));
51 for (i
= 0; i
< ARRAY_SIZE(models
); i
++) {
52 if (strcmp(models
[i
], model
) == 0)
56 return (i
< ARRAY_SIZE(models
));
59 static int name_card(struct snd_oxfw
*oxfw
)
61 struct fw_device
*fw_dev
= fw_parent_device(oxfw
->unit
);
64 const char *d
, *v
, *m
;
68 /* get vendor name from root directory */
69 err
= fw_csr_string(fw_dev
->config_rom
+ 5, CSR_VENDOR
,
70 vendor
, sizeof(vendor
));
74 /* get model name from unit directory */
75 err
= fw_csr_string(oxfw
->unit
->directory
, CSR_MODEL
,
76 model
, sizeof(model
));
80 err
= snd_fw_transaction(oxfw
->unit
, TCODE_READ_QUADLET_REQUEST
,
81 OXFORD_FIRMWARE_ID_ADDRESS
, &firmware
, 4, 0);
84 be32_to_cpus(&firmware
);
86 /* to apply card definitions */
87 if (oxfw
->device_info
) {
88 d
= oxfw
->device_info
->driver_name
;
89 v
= oxfw
->device_info
->vendor_name
;
90 m
= oxfw
->device_info
->model_name
;
97 strcpy(oxfw
->card
->driver
, d
);
98 strcpy(oxfw
->card
->mixername
, m
);
99 strcpy(oxfw
->card
->shortname
, m
);
101 snprintf(oxfw
->card
->longname
, sizeof(oxfw
->card
->longname
),
102 "%s %s (OXFW%x %04x), GUID %08x%08x at %s, S%d",
103 v
, m
, firmware
>> 20, firmware
& 0xffff,
104 fw_dev
->config_rom
[3], fw_dev
->config_rom
[4],
105 dev_name(&oxfw
->unit
->device
), 100 << fw_dev
->max_speed
);
111 * This module releases the FireWire unit data after all ALSA character devices
112 * are released by applications. This is for releasing stream data or finishing
113 * transactions safely. Thus at returning from .remove(), this module still keep
114 * references for the unit.
116 static void oxfw_card_free(struct snd_card
*card
)
118 struct snd_oxfw
*oxfw
= card
->private_data
;
121 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
122 if (oxfw
->has_output
)
123 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
125 fw_unit_put(oxfw
->unit
);
127 for (i
= 0; i
< SND_OXFW_STREAM_FORMAT_ENTRIES
; i
++) {
128 kfree(oxfw
->tx_stream_formats
[i
]);
129 kfree(oxfw
->rx_stream_formats
[i
]);
132 mutex_destroy(&oxfw
->mutex
);
135 static void detect_quirks(struct snd_oxfw
*oxfw
)
137 struct fw_device
*fw_dev
= fw_parent_device(oxfw
->unit
);
138 struct fw_csr_iterator it
;
142 /* Seek from Root Directory of Config ROM. */
144 fw_csr_iterator_init(&it
, fw_dev
->config_rom
+ 5);
145 while (fw_csr_iterator_next(&it
, &key
, &val
)) {
146 if (key
== CSR_VENDOR
)
148 else if (key
== CSR_MODEL
)
153 * Mackie Onyx Satellite with base station has a quirk to report a wrong
154 * value in 'dbs' field of CIP header against its format information.
156 if (vendor
== VENDOR_LOUD
&& model
== MODEL_SATELLITE
)
157 oxfw
->wrong_dbs
= true;
160 * TASCAM FireOne has physical control and requires a pair of additional
163 if (vendor
== VENDOR_TASCAM
) {
164 oxfw
->midi_input_ports
++;
165 oxfw
->midi_output_ports
++;
169 static int oxfw_probe(struct fw_unit
*unit
,
170 const struct ieee1394_device_id
*id
)
172 struct snd_card
*card
;
173 struct snd_oxfw
*oxfw
;
176 if ((id
->vendor_id
== VENDOR_LOUD
) && !detect_loud_models(unit
))
179 err
= snd_card_new(&unit
->device
, -1, NULL
, THIS_MODULE
,
180 sizeof(*oxfw
), &card
);
184 card
->private_free
= oxfw_card_free
;
185 oxfw
= card
->private_data
;
187 mutex_init(&oxfw
->mutex
);
188 oxfw
->unit
= fw_unit_get(unit
);
189 oxfw
->device_info
= (const struct device_info
*)id
->driver_data
;
190 spin_lock_init(&oxfw
->lock
);
191 init_waitqueue_head(&oxfw
->hwdep_wait
);
193 err
= snd_oxfw_stream_discover(oxfw
);
199 err
= name_card(oxfw
);
203 err
= snd_oxfw_create_pcm(oxfw
);
207 if (oxfw
->device_info
) {
208 err
= snd_oxfw_create_mixer(oxfw
);
213 snd_oxfw_proc_init(oxfw
);
215 err
= snd_oxfw_create_midi(oxfw
);
219 err
= snd_oxfw_create_hwdep(oxfw
);
223 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->rx_stream
);
226 if (oxfw
->has_output
) {
227 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->tx_stream
);
232 err
= snd_card_register(card
);
234 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
235 if (oxfw
->has_output
)
236 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
239 dev_set_drvdata(&unit
->device
, oxfw
);
247 static void oxfw_bus_reset(struct fw_unit
*unit
)
249 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
251 fcp_bus_reset(oxfw
->unit
);
253 mutex_lock(&oxfw
->mutex
);
255 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->rx_stream
);
256 if (oxfw
->has_output
)
257 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->tx_stream
);
259 mutex_unlock(&oxfw
->mutex
);
262 static void oxfw_remove(struct fw_unit
*unit
)
264 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
266 /* No need to wait for releasing card object in this context. */
267 snd_card_free_when_closed(oxfw
->card
);
270 static const struct device_info griffin_firewave
= {
271 .driver_name
= "FireWave",
272 .vendor_name
= "Griffin",
273 .model_name
= "FireWave",
276 .volume_fb_id
= 0x02,
279 static const struct device_info lacie_speakers
= {
280 .driver_name
= "FWSpeakers",
281 .vendor_name
= "LaCie",
282 .model_name
= "FireWire Speakers",
285 .volume_fb_id
= 0x01,
288 static const struct ieee1394_device_id oxfw_id_table
[] = {
290 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
291 IEEE1394_MATCH_MODEL_ID
|
292 IEEE1394_MATCH_SPECIFIER_ID
|
293 IEEE1394_MATCH_VERSION
,
294 .vendor_id
= VENDOR_GRIFFIN
,
295 .model_id
= 0x00f970,
296 .specifier_id
= SPECIFIER_1394TA
,
297 .version
= VERSION_AVC
,
298 .driver_data
= (kernel_ulong_t
)&griffin_firewave
,
301 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
302 IEEE1394_MATCH_MODEL_ID
|
303 IEEE1394_MATCH_SPECIFIER_ID
|
304 IEEE1394_MATCH_VERSION
,
305 .vendor_id
= VENDOR_LACIE
,
306 .model_id
= 0x00f970,
307 .specifier_id
= SPECIFIER_1394TA
,
308 .version
= VERSION_AVC
,
309 .driver_data
= (kernel_ulong_t
)&lacie_speakers
,
311 /* Behringer,F-Control Audio 202 */
313 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
314 IEEE1394_MATCH_MODEL_ID
,
315 .vendor_id
= VENDOR_BEHRINGER
,
316 .model_id
= 0x00fc22,
319 * Any Mackie(Loud) models (name string/model id):
320 * Onyx-i series (former models): 0x081216
321 * Mackie Onyx Satellite: 0x00200f
322 * Tapco LINK.firewire 4x6: 0x000460
329 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
330 IEEE1394_MATCH_SPECIFIER_ID
|
331 IEEE1394_MATCH_VERSION
,
332 .vendor_id
= VENDOR_LOUD
,
333 .specifier_id
= SPECIFIER_1394TA
,
334 .version
= VERSION_AVC
,
336 /* TASCAM, FireOne */
338 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
339 IEEE1394_MATCH_MODEL_ID
,
340 .vendor_id
= VENDOR_TASCAM
,
341 .model_id
= 0x800007,
345 MODULE_DEVICE_TABLE(ieee1394
, oxfw_id_table
);
347 static struct fw_driver oxfw_driver
= {
349 .owner
= THIS_MODULE
,
350 .name
= KBUILD_MODNAME
,
354 .update
= oxfw_bus_reset
,
355 .remove
= oxfw_remove
,
356 .id_table
= oxfw_id_table
,
359 static int __init
snd_oxfw_init(void)
361 return driver_register(&oxfw_driver
.driver
);
364 static void __exit
snd_oxfw_exit(void)
366 driver_unregister(&oxfw_driver
.driver
);
369 module_init(snd_oxfw_init
);
370 module_exit(snd_oxfw_exit
);