0001
0002
0003
0004
0005
0006
0007
0008 #include "digi00x.h"
0009
0010 MODULE_DESCRIPTION("Digidesign Digi 002/003 family Driver");
0011 MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
0012 MODULE_LICENSE("GPL v2");
0013
0014 #define VENDOR_DIGIDESIGN 0x00a07e
0015 #define MODEL_CONSOLE 0x000001
0016 #define MODEL_RACK 0x000002
0017 #define SPEC_VERSION 0x000001
0018
0019 static int name_card(struct snd_dg00x *dg00x)
0020 {
0021 struct fw_device *fw_dev = fw_parent_device(dg00x->unit);
0022 char name[32] = {0};
0023 char *model;
0024 int err;
0025
0026 err = fw_csr_string(dg00x->unit->directory, CSR_MODEL, name,
0027 sizeof(name));
0028 if (err < 0)
0029 return err;
0030
0031 model = skip_spaces(name);
0032
0033 strcpy(dg00x->card->driver, "Digi00x");
0034 strcpy(dg00x->card->shortname, model);
0035 strcpy(dg00x->card->mixername, model);
0036 snprintf(dg00x->card->longname, sizeof(dg00x->card->longname),
0037 "Digidesign %s, GUID %08x%08x at %s, S%d", model,
0038 fw_dev->config_rom[3], fw_dev->config_rom[4],
0039 dev_name(&dg00x->unit->device), 100 << fw_dev->max_speed);
0040
0041 return 0;
0042 }
0043
0044 static void dg00x_card_free(struct snd_card *card)
0045 {
0046 struct snd_dg00x *dg00x = card->private_data;
0047
0048 snd_dg00x_stream_destroy_duplex(dg00x);
0049 snd_dg00x_transaction_unregister(dg00x);
0050
0051 mutex_destroy(&dg00x->mutex);
0052 fw_unit_put(dg00x->unit);
0053 }
0054
0055 static int snd_dg00x_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry)
0056 {
0057 struct snd_card *card;
0058 struct snd_dg00x *dg00x;
0059 int err;
0060
0061 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*dg00x), &card);
0062 if (err < 0)
0063 return err;
0064 card->private_free = dg00x_card_free;
0065
0066 dg00x = card->private_data;
0067 dg00x->unit = fw_unit_get(unit);
0068 dev_set_drvdata(&unit->device, dg00x);
0069 dg00x->card = card;
0070
0071 mutex_init(&dg00x->mutex);
0072 spin_lock_init(&dg00x->lock);
0073 init_waitqueue_head(&dg00x->hwdep_wait);
0074
0075 dg00x->is_console = entry->model_id == MODEL_CONSOLE;
0076
0077 err = name_card(dg00x);
0078 if (err < 0)
0079 goto error;
0080
0081 err = snd_dg00x_stream_init_duplex(dg00x);
0082 if (err < 0)
0083 goto error;
0084
0085 snd_dg00x_proc_init(dg00x);
0086
0087 err = snd_dg00x_create_pcm_devices(dg00x);
0088 if (err < 0)
0089 goto error;
0090
0091 err = snd_dg00x_create_midi_devices(dg00x);
0092 if (err < 0)
0093 goto error;
0094
0095 err = snd_dg00x_create_hwdep_device(dg00x);
0096 if (err < 0)
0097 goto error;
0098
0099 err = snd_dg00x_transaction_register(dg00x);
0100 if (err < 0)
0101 goto error;
0102
0103 err = snd_card_register(card);
0104 if (err < 0)
0105 goto error;
0106
0107 return 0;
0108 error:
0109 snd_card_free(card);
0110 return err;
0111 }
0112
0113 static void snd_dg00x_update(struct fw_unit *unit)
0114 {
0115 struct snd_dg00x *dg00x = dev_get_drvdata(&unit->device);
0116
0117 snd_dg00x_transaction_reregister(dg00x);
0118
0119 mutex_lock(&dg00x->mutex);
0120 snd_dg00x_stream_update_duplex(dg00x);
0121 mutex_unlock(&dg00x->mutex);
0122 }
0123
0124 static void snd_dg00x_remove(struct fw_unit *unit)
0125 {
0126 struct snd_dg00x *dg00x = dev_get_drvdata(&unit->device);
0127
0128
0129 snd_card_free(dg00x->card);
0130 }
0131
0132 static const struct ieee1394_device_id snd_dg00x_id_table[] = {
0133
0134 {
0135 .match_flags = IEEE1394_MATCH_VENDOR_ID |
0136 IEEE1394_MATCH_VERSION |
0137 IEEE1394_MATCH_MODEL_ID,
0138 .vendor_id = VENDOR_DIGIDESIGN,
0139 .version = SPEC_VERSION,
0140 .model_id = MODEL_CONSOLE,
0141 },
0142 {
0143 .match_flags = IEEE1394_MATCH_VENDOR_ID |
0144 IEEE1394_MATCH_VERSION |
0145 IEEE1394_MATCH_MODEL_ID,
0146 .vendor_id = VENDOR_DIGIDESIGN,
0147 .version = SPEC_VERSION,
0148 .model_id = MODEL_RACK,
0149 },
0150 {}
0151 };
0152 MODULE_DEVICE_TABLE(ieee1394, snd_dg00x_id_table);
0153
0154 static struct fw_driver dg00x_driver = {
0155 .driver = {
0156 .owner = THIS_MODULE,
0157 .name = KBUILD_MODNAME,
0158 .bus = &fw_bus_type,
0159 },
0160 .probe = snd_dg00x_probe,
0161 .update = snd_dg00x_update,
0162 .remove = snd_dg00x_remove,
0163 .id_table = snd_dg00x_id_table,
0164 };
0165
0166 static int __init snd_dg00x_init(void)
0167 {
0168 return driver_register(&dg00x_driver.driver);
0169 }
0170
0171 static void __exit snd_dg00x_exit(void)
0172 {
0173 driver_unregister(&dg00x_driver.driver);
0174 }
0175
0176 module_init(snd_dg00x_init);
0177 module_exit(snd_dg00x_exit);