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
);
108 * This module releases the FireWire unit data after all ALSA character devices
109 * are released by applications. This is for releasing stream data or finishing
110 * transactions safely. Thus at returning from .remove(), this module still keep
111 * references for the unit.
113 static void oxfw_card_free(struct snd_card
*card
)
115 struct snd_oxfw
*oxfw
= card
->private_data
;
118 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
119 if (oxfw
->has_output
)
120 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
122 fw_unit_put(oxfw
->unit
);
124 for (i
= 0; i
< SND_OXFW_STREAM_FORMAT_ENTRIES
; i
++) {
125 kfree(oxfw
->tx_stream_formats
[i
]);
126 kfree(oxfw
->rx_stream_formats
[i
]);
129 mutex_destroy(&oxfw
->mutex
);
132 static int oxfw_probe(struct fw_unit
*unit
,
133 const struct ieee1394_device_id
*id
)
135 struct snd_card
*card
;
136 struct snd_oxfw
*oxfw
;
139 if ((id
->vendor_id
== VENDOR_LOUD
) && !detect_loud_models(unit
))
142 err
= snd_card_new(&unit
->device
, -1, NULL
, THIS_MODULE
,
143 sizeof(*oxfw
), &card
);
147 card
->private_free
= oxfw_card_free
;
148 oxfw
= card
->private_data
;
150 mutex_init(&oxfw
->mutex
);
151 oxfw
->unit
= fw_unit_get(unit
);
152 oxfw
->device_info
= (const struct device_info
*)id
->driver_data
;
153 spin_lock_init(&oxfw
->lock
);
154 init_waitqueue_head(&oxfw
->hwdep_wait
);
156 err
= snd_oxfw_stream_discover(oxfw
);
160 err
= name_card(oxfw
);
164 err
= snd_oxfw_create_pcm(oxfw
);
168 if (oxfw
->device_info
) {
169 err
= snd_oxfw_create_mixer(oxfw
);
174 snd_oxfw_proc_init(oxfw
);
176 err
= snd_oxfw_create_midi(oxfw
);
180 err
= snd_oxfw_create_hwdep(oxfw
);
184 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->rx_stream
);
187 if (oxfw
->has_output
) {
188 err
= snd_oxfw_stream_init_simplex(oxfw
, &oxfw
->tx_stream
);
193 err
= snd_card_register(card
);
195 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->rx_stream
);
196 if (oxfw
->has_output
)
197 snd_oxfw_stream_destroy_simplex(oxfw
, &oxfw
->tx_stream
);
200 dev_set_drvdata(&unit
->device
, oxfw
);
208 static void oxfw_bus_reset(struct fw_unit
*unit
)
210 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
212 fcp_bus_reset(oxfw
->unit
);
214 mutex_lock(&oxfw
->mutex
);
216 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->rx_stream
);
217 if (oxfw
->has_output
)
218 snd_oxfw_stream_update_simplex(oxfw
, &oxfw
->tx_stream
);
220 mutex_unlock(&oxfw
->mutex
);
223 static void oxfw_remove(struct fw_unit
*unit
)
225 struct snd_oxfw
*oxfw
= dev_get_drvdata(&unit
->device
);
227 /* No need to wait for releasing card object in this context. */
228 snd_card_free_when_closed(oxfw
->card
);
231 static const struct device_info griffin_firewave
= {
232 .driver_name
= "FireWave",
233 .vendor_name
= "Griffin",
234 .model_name
= "FireWave",
237 .volume_fb_id
= 0x02,
240 static const struct device_info lacie_speakers
= {
241 .driver_name
= "FWSpeakers",
242 .vendor_name
= "LaCie",
243 .model_name
= "FireWire Speakers",
246 .volume_fb_id
= 0x01,
249 static const struct ieee1394_device_id oxfw_id_table
[] = {
251 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
252 IEEE1394_MATCH_MODEL_ID
|
253 IEEE1394_MATCH_SPECIFIER_ID
|
254 IEEE1394_MATCH_VERSION
,
255 .vendor_id
= VENDOR_GRIFFIN
,
256 .model_id
= 0x00f970,
257 .specifier_id
= SPECIFIER_1394TA
,
258 .version
= VERSION_AVC
,
259 .driver_data
= (kernel_ulong_t
)&griffin_firewave
,
262 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
263 IEEE1394_MATCH_MODEL_ID
|
264 IEEE1394_MATCH_SPECIFIER_ID
|
265 IEEE1394_MATCH_VERSION
,
266 .vendor_id
= VENDOR_LACIE
,
267 .model_id
= 0x00f970,
268 .specifier_id
= SPECIFIER_1394TA
,
269 .version
= VERSION_AVC
,
270 .driver_data
= (kernel_ulong_t
)&lacie_speakers
,
272 /* Behringer,F-Control Audio 202 */
274 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
275 IEEE1394_MATCH_MODEL_ID
,
276 .vendor_id
= VENDOR_BEHRINGER
,
277 .model_id
= 0x00fc22,
280 * Any Mackie(Loud) models (name string/model id):
281 * Onyx-i series (former models): 0x081216
282 * Mackie Onyx Satellite: 0x00200f
283 * Tapco LINK.firewire 4x6: 0x000460
290 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
291 IEEE1394_MATCH_SPECIFIER_ID
|
292 IEEE1394_MATCH_VERSION
,
293 .vendor_id
= VENDOR_LOUD
,
294 .specifier_id
= SPECIFIER_1394TA
,
295 .version
= VERSION_AVC
,
299 MODULE_DEVICE_TABLE(ieee1394
, oxfw_id_table
);
301 static struct fw_driver oxfw_driver
= {
303 .owner
= THIS_MODULE
,
304 .name
= KBUILD_MODNAME
,
308 .update
= oxfw_bus_reset
,
309 .remove
= oxfw_remove
,
310 .id_table
= oxfw_id_table
,
313 static int __init
snd_oxfw_init(void)
315 return driver_register(&oxfw_driver
.driver
);
318 static void __exit
snd_oxfw_exit(void)
320 driver_unregister(&oxfw_driver
.driver
);
323 module_init(snd_oxfw_init
);
324 module_exit(snd_oxfw_exit
);