2 * digi00x.c - a part of driver for Digidesign Digi 002/003 family
4 * Copyright (c) 2014-2015 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
11 MODULE_DESCRIPTION("Digidesign Digi 002/003 family Driver");
12 MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
13 MODULE_LICENSE("GPL v2");
15 #define VENDOR_DIGIDESIGN 0x00a07e
16 #define MODEL_CONSOLE 0x000001
17 #define MODEL_RACK 0x000002
18 #define SPEC_VERSION 0x000001
20 static int name_card(struct snd_dg00x *dg00x)
22 struct fw_device *fw_dev = fw_parent_device(dg00x->unit);
27 err = fw_csr_string(dg00x->unit->directory, CSR_MODEL, name,
32 model = skip_spaces(name);
34 strcpy(dg00x->card->driver, "Digi00x");
35 strcpy(dg00x->card->shortname, model);
36 strcpy(dg00x->card->mixername, model);
37 snprintf(dg00x->card->longname, sizeof(dg00x->card->longname),
38 "Digidesign %s, GUID %08x%08x at %s, S%d", model,
39 fw_dev->config_rom[3], fw_dev->config_rom[4],
40 dev_name(&dg00x->unit->device), 100 << fw_dev->max_speed);
45 static void dg00x_card_free(struct snd_card *card)
47 struct snd_dg00x *dg00x = card->private_data;
49 snd_dg00x_stream_destroy_duplex(dg00x);
50 snd_dg00x_transaction_unregister(dg00x);
52 fw_unit_put(dg00x->unit);
54 mutex_destroy(&dg00x->mutex);
57 static int snd_dg00x_probe(struct fw_unit *unit,
58 const struct ieee1394_device_id *entry)
60 struct snd_card *card;
61 struct snd_dg00x *dg00x;
65 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
66 sizeof(struct snd_dg00x), &card);
69 card->private_free = dg00x_card_free;
71 /* initialize myself */
72 dg00x = card->private_data;
74 dg00x->unit = fw_unit_get(unit);
76 mutex_init(&dg00x->mutex);
77 spin_lock_init(&dg00x->lock);
78 init_waitqueue_head(&dg00x->hwdep_wait);
80 dg00x->is_console = entry->model_id == MODEL_CONSOLE;
82 err = name_card(dg00x);
86 err = snd_dg00x_stream_init_duplex(dg00x);
90 snd_dg00x_proc_init(dg00x);
92 err = snd_dg00x_create_pcm_devices(dg00x);
96 err = snd_dg00x_create_midi_devices(dg00x);
100 err = snd_dg00x_create_hwdep_device(dg00x);
104 err = snd_dg00x_transaction_register(dg00x);
108 err = snd_card_register(card);
112 dev_set_drvdata(&unit->device, dg00x);
120 static void snd_dg00x_update(struct fw_unit *unit)
122 struct snd_dg00x *dg00x = dev_get_drvdata(&unit->device);
124 snd_dg00x_transaction_reregister(dg00x);
126 mutex_lock(&dg00x->mutex);
127 snd_dg00x_stream_update_duplex(dg00x);
128 mutex_unlock(&dg00x->mutex);
131 static void snd_dg00x_remove(struct fw_unit *unit)
133 struct snd_dg00x *dg00x = dev_get_drvdata(&unit->device);
135 /* No need to wait for releasing card object in this context. */
136 snd_card_free_when_closed(dg00x->card);
139 static const struct ieee1394_device_id snd_dg00x_id_table[] = {
140 /* Both of 002/003 use the same ID. */
142 .match_flags = IEEE1394_MATCH_VENDOR_ID |
143 IEEE1394_MATCH_VERSION |
144 IEEE1394_MATCH_MODEL_ID,
145 .vendor_id = VENDOR_DIGIDESIGN,
146 .version = SPEC_VERSION,
147 .model_id = MODEL_CONSOLE,
150 .match_flags = IEEE1394_MATCH_VENDOR_ID |
151 IEEE1394_MATCH_VERSION |
152 IEEE1394_MATCH_MODEL_ID,
153 .vendor_id = VENDOR_DIGIDESIGN,
154 .version = SPEC_VERSION,
155 .model_id = MODEL_RACK,
159 MODULE_DEVICE_TABLE(ieee1394, snd_dg00x_id_table);
161 static struct fw_driver dg00x_driver = {
163 .owner = THIS_MODULE,
164 .name = "snd-firewire-digi00x",
167 .probe = snd_dg00x_probe,
168 .update = snd_dg00x_update,
169 .remove = snd_dg00x_remove,
170 .id_table = snd_dg00x_id_table,
173 static int __init snd_dg00x_init(void)
175 return driver_register(&dg00x_driver.driver);
178 static void __exit snd_dg00x_exit(void)
180 driver_unregister(&dg00x_driver.driver);
183 module_init(snd_dg00x_init);
184 module_exit(snd_dg00x_exit);