summaryrefslogtreecommitdiffstats
path: root/sound/firewire/motu
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2017-03-22 08:30:11 -0400
committerTakashi Iwai <tiwai@suse.de>2017-03-28 06:33:16 -0400
commit6c3cef4890d072afa2d77371f358abaea54ec134 (patch)
treed7d0b5d551d3c90079b0358d06e93b35e7441b9b /sound/firewire/motu
parent13f99ebdd602ebdafb909e15ec6ffb1e34690167 (diff)
ALSA: firewire-motu: add skeleton for Mark of the unicorn (MOTU) FireWire series
This commit adds an new driver for MOTU FireWire series. In this commit, this driver just creates/removes card instance according to bus event. More functionalities will be added in following commits. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/motu')
-rw-r--r--sound/firewire/motu/Makefile2
-rw-r--r--sound/firewire/motu/motu.c134
-rw-r--r--sound/firewire/motu/motu.h29
3 files changed, 165 insertions, 0 deletions
diff --git a/sound/firewire/motu/Makefile b/sound/firewire/motu/Makefile
new file mode 100644
index 000000000000..d7819d57eadf
--- /dev/null
+++ b/sound/firewire/motu/Makefile
@@ -0,0 +1,2 @@
1snd-firewire-motu-objs := motu.o
2obj-$(CONFIG_SND_FIREWIRE_MOTU) += snd-firewire-motu.o
diff --git a/sound/firewire/motu/motu.c b/sound/firewire/motu/motu.c
new file mode 100644
index 000000000000..2684e7447432
--- /dev/null
+++ b/sound/firewire/motu/motu.c
@@ -0,0 +1,134 @@
1/*
2 * motu.c - a part of driver for MOTU FireWire series
3 *
4 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include "motu.h"
10
11#define OUI_MOTU 0x0001f2
12
13MODULE_DESCRIPTION("MOTU FireWire driver");
14MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
15MODULE_LICENSE("GPL v2");
16
17static void name_card(struct snd_motu *motu)
18{
19 struct fw_device *fw_dev = fw_parent_device(motu->unit);
20 struct fw_csr_iterator it;
21 int key, val;
22 u32 version = 0;
23
24 fw_csr_iterator_init(&it, motu->unit->directory);
25 while (fw_csr_iterator_next(&it, &key, &val)) {
26 switch (key) {
27 case CSR_VERSION:
28 version = val;
29 break;
30 }
31 }
32
33 strcpy(motu->card->driver, "FW-MOTU");
34 snprintf(motu->card->longname, sizeof(motu->card->longname),
35 "MOTU (version:%d), GUID %08x%08x at %s, S%d",
36 version,
37 fw_dev->config_rom[3], fw_dev->config_rom[4],
38 dev_name(&motu->unit->device), 100 << fw_dev->max_speed);
39}
40
41static void motu_card_free(struct snd_card *card)
42{
43 struct snd_motu *motu = card->private_data;
44
45 fw_unit_put(motu->unit);
46
47 mutex_destroy(&motu->mutex);
48}
49
50static int motu_probe(struct fw_unit *unit,
51 const struct ieee1394_device_id *entry)
52{
53 struct snd_card *card;
54 struct snd_motu *motu;
55 int err;
56
57 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
58 sizeof(*motu), &card);
59 if (err < 0)
60 return err;
61
62 motu = card->private_data;
63 motu->card = card;
64 motu->unit = fw_unit_get(unit);
65 card->private_free = motu_card_free;
66
67 mutex_init(&motu->mutex);
68
69 name_card(motu);
70
71 err = snd_card_register(card);
72 if (err < 0)
73 goto error;
74
75 dev_set_drvdata(&unit->device, motu);
76
77 return 0;
78error:
79 snd_card_free(card);
80 return err;
81}
82
83static void motu_remove(struct fw_unit *unit)
84{
85 struct snd_motu *motu = dev_get_drvdata(&unit->device);
86
87 /* No need to wait for releasing card object in this context. */
88 snd_card_free_when_closed(motu->card);
89}
90
91static void motu_bus_update(struct fw_unit *unit)
92{
93 return;
94}
95
96#define SND_MOTU_DEV_ENTRY(model) \
97{ \
98 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
99 IEEE1394_MATCH_MODEL_ID | \
100 IEEE1394_MATCH_SPECIFIER_ID, \
101 .vendor_id = OUI_MOTU, \
102 .model_id = model, \
103 .specifier_id = OUI_MOTU, \
104}
105
106static const struct ieee1394_device_id motu_id_table[] = {
107 { }
108};
109MODULE_DEVICE_TABLE(ieee1394, motu_id_table);
110
111static struct fw_driver motu_driver = {
112 .driver = {
113 .owner = THIS_MODULE,
114 .name = KBUILD_MODNAME,
115 .bus = &fw_bus_type,
116 },
117 .probe = motu_probe,
118 .update = motu_bus_update,
119 .remove = motu_remove,
120 .id_table = motu_id_table,
121};
122
123static int __init alsa_motu_init(void)
124{
125 return driver_register(&motu_driver.driver);
126}
127
128static void __exit alsa_motu_exit(void)
129{
130 driver_unregister(&motu_driver.driver);
131}
132
133module_init(alsa_motu_init);
134module_exit(alsa_motu_exit);
diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h
new file mode 100644
index 000000000000..f3d0b2834942
--- /dev/null
+++ b/sound/firewire/motu/motu.h
@@ -0,0 +1,29 @@
1/*
2 * motu.h - a part of driver for MOTU FireWire series
3 *
4 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#ifndef SOUND_FIREWIRE_MOTU_H_INCLUDED
10#define SOUND_FIREWIRE_MOTU_H_INCLUDED
11
12#include <linux/device.h>
13#include <linux/firewire.h>
14#include <linux/firewire-constants.h>
15#include <linux/module.h>
16#include <linux/mod_devicetable.h>
17#include <linux/mutex.h>
18#include <linux/slab.h>
19
20#include <sound/control.h>
21#include <sound/core.h>
22
23struct snd_motu {
24 struct snd_card *card;
25 struct fw_unit *unit;
26 struct mutex mutex;
27};
28
29#endif