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_DIGI00X 0x000002
18 static int name_card(struct snd_dg00x
*dg00x
)
20 struct fw_device
*fw_dev
= fw_parent_device(dg00x
->unit
);
25 err
= fw_csr_string(dg00x
->unit
->directory
, CSR_MODEL
, name
,
30 model
= skip_spaces(name
);
32 strcpy(dg00x
->card
->driver
, "Digi00x");
33 strcpy(dg00x
->card
->shortname
, model
);
34 strcpy(dg00x
->card
->mixername
, model
);
35 snprintf(dg00x
->card
->longname
, sizeof(dg00x
->card
->longname
),
36 "Digidesign %s, GUID %08x%08x at %s, S%d", model
,
37 fw_dev
->config_rom
[3], fw_dev
->config_rom
[4],
38 dev_name(&dg00x
->unit
->device
), 100 << fw_dev
->max_speed
);
43 static void dg00x_card_free(struct snd_card
*card
)
45 struct snd_dg00x
*dg00x
= card
->private_data
;
47 snd_dg00x_stream_destroy_duplex(dg00x
);
48 snd_dg00x_transaction_unregister(dg00x
);
50 fw_unit_put(dg00x
->unit
);
52 mutex_destroy(&dg00x
->mutex
);
55 static int snd_dg00x_probe(struct fw_unit
*unit
,
56 const struct ieee1394_device_id
*entry
)
58 struct snd_card
*card
;
59 struct snd_dg00x
*dg00x
;
63 err
= snd_card_new(&unit
->device
, -1, NULL
, THIS_MODULE
,
64 sizeof(struct snd_dg00x
), &card
);
67 card
->private_free
= dg00x_card_free
;
69 /* initialize myself */
70 dg00x
= card
->private_data
;
72 dg00x
->unit
= fw_unit_get(unit
);
74 mutex_init(&dg00x
->mutex
);
75 spin_lock_init(&dg00x
->lock
);
76 init_waitqueue_head(&dg00x
->hwdep_wait
);
78 err
= name_card(dg00x
);
82 err
= snd_dg00x_stream_init_duplex(dg00x
);
86 snd_dg00x_proc_init(dg00x
);
88 err
= snd_dg00x_create_pcm_devices(dg00x
);
92 err
= snd_dg00x_create_midi_devices(dg00x
);
96 err
= snd_dg00x_create_hwdep_device(dg00x
);
100 err
= snd_dg00x_transaction_register(dg00x
);
104 err
= snd_card_register(card
);
108 dev_set_drvdata(&unit
->device
, dg00x
);
116 static void snd_dg00x_update(struct fw_unit
*unit
)
118 struct snd_dg00x
*dg00x
= dev_get_drvdata(&unit
->device
);
120 snd_dg00x_transaction_reregister(dg00x
);
122 mutex_lock(&dg00x
->mutex
);
123 snd_dg00x_stream_update_duplex(dg00x
);
124 mutex_unlock(&dg00x
->mutex
);
127 static void snd_dg00x_remove(struct fw_unit
*unit
)
129 struct snd_dg00x
*dg00x
= dev_get_drvdata(&unit
->device
);
131 /* No need to wait for releasing card object in this context. */
132 snd_card_free_when_closed(dg00x
->card
);
135 static const struct ieee1394_device_id snd_dg00x_id_table
[] = {
136 /* Both of 002/003 use the same ID. */
138 .match_flags
= IEEE1394_MATCH_VENDOR_ID
|
139 IEEE1394_MATCH_MODEL_ID
,
140 .vendor_id
= VENDOR_DIGIDESIGN
,
141 .model_id
= MODEL_DIGI00X
,
145 MODULE_DEVICE_TABLE(ieee1394
, snd_dg00x_id_table
);
147 static struct fw_driver dg00x_driver
= {
149 .owner
= THIS_MODULE
,
150 .name
= "snd-firewire-digi00x",
153 .probe
= snd_dg00x_probe
,
154 .update
= snd_dg00x_update
,
155 .remove
= snd_dg00x_remove
,
156 .id_table
= snd_dg00x_id_table
,
159 static int __init
snd_dg00x_init(void)
161 return driver_register(&dg00x_driver
.driver
);
164 static void __exit
snd_dg00x_exit(void)
166 driver_unregister(&dg00x_driver
.driver
);
169 module_init(snd_dg00x_init
);
170 module_exit(snd_dg00x_exit
);