aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire/bebob/bebob_maudio.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-04-25 09:45:25 -0400
committerTakashi Iwai <tiwai@suse.de>2014-05-26 08:32:03 -0400
commit9076c22ddd9d29a30426f0367dec2b40e12536de (patch)
tree8fd173e744c1080bdc13e0c9cdb486d4094fb2e4 /sound/firewire/bebob/bebob_maudio.c
parent25784ec2d0347b715e354d92151734afe1296f02 (diff)
ALSA: bebob: Add support for M-Audio usual Firewire series
This commit allows this driver to support some models which M-Audio produces with DM1000/DM1000E with usual firmware. They are: - Firewire 410 - Firewire AudioPhile - Firewire Solo - Ozonic - NRV10 - FirewireLightBridge According to a person who worked in BridgeCo, some models are produced with 'Pre-BeBoB'. This means that these products were released before BeBoB was officially produced, and later BeBoB specification was formed. So these models have some quirks. M-Audio usual firmware quirks: - Just after powering on, 'Firewire 410' waits to download firmware. This state is changed when receiving cue. Then bus reset is generated and the device is recognized as a different model with the uploaded firmware. - 'Firewire Audiophile' also waits to download firmware but its vendor id/model id is the same as the one after loading firmware. - The information of channel mapping for MIDI conformant data channel is invalid against BridgeCo specification. This commit adds some codes for these quirks but don't support to upload firmware. This commit also adds specific operations to get metering information. The metering information also includes status of clock synchronization if the model supports to switch source of clock. The specification of FirewireLightBridge is unknown. So in this time, normal operations are applied for this model. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob/bebob_maudio.c')
-rw-r--r--sound/firewire/bebob/bebob_maudio.c180
1 files changed, 180 insertions, 0 deletions
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
new file mode 100644
index 000000000000..dededb35fbd7
--- /dev/null
+++ b/sound/firewire/bebob/bebob_maudio.c
@@ -0,0 +1,180 @@
1/*
2 * bebob_maudio.c - a part of driver for BeBoB based devices
3 *
4 * Copyright (c) 2013-2014 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include "./bebob.h"
10
11/*
12 * Just powering on, Firewire 410/Audiophile wait to
13 * download firmware blob. To enable these devices, drivers should upload
14 * firmware blob and send a command to initialize configuration to factory
15 * settings when completing uploading. Then these devices generate bus reset
16 * and are recognized as new devices with the firmware.
17 *
18 * For streaming, both of output and input streams are needed for Firewire 410
19 * and Ozonic. The single stream is OK for the other devices even if the clock
20 * source is not SYT-Match (I note no devices use SYT-Match).
21 *
22 * Without streaming, the devices except for Firewire Audiophile can mix any
23 * input and output. For this reason, Audiophile cannot be used as standalone
24 * mixer.
25 */
26
27#define MAUDIO_SPECIFIC_ADDRESS 0xffc700000000
28
29#define METER_OFFSET 0x00600000
30
31/* some device has sync info after metering data */
32#define METER_SIZE_FW410 76 /* with sync info */
33#define METER_SIZE_AUDIOPHILE 60 /* with sync info */
34#define METER_SIZE_SOLO 52 /* with sync info */
35#define METER_SIZE_OZONIC 48
36#define METER_SIZE_NRV10 80
37
38/* labels for metering */
39#define ANA_IN "Analog In"
40#define ANA_OUT "Analog Out"
41#define DIG_IN "Digital In"
42#define SPDIF_IN "S/PDIF In"
43#define ADAT_IN "ADAT In"
44#define DIG_OUT "Digital Out"
45#define SPDIF_OUT "S/PDIF Out"
46#define ADAT_OUT "ADAT Out"
47#define STRM_IN "Stream In"
48#define AUX_OUT "Aux Out"
49#define HP_OUT "HP Out"
50/* for NRV */
51#define UNKNOWN_METER "Unknown"
52
53static inline int
54get_meter(struct snd_bebob *bebob, void *buf, unsigned int size)
55{
56 return snd_fw_transaction(bebob->unit, TCODE_READ_BLOCK_REQUEST,
57 MAUDIO_SPECIFIC_ADDRESS + METER_OFFSET,
58 buf, size, 0);
59}
60
61/* last 4 bytes are omitted because it's clock info. */
62static char *const fw410_meter_labels[] = {
63 ANA_IN, DIG_IN,
64 ANA_OUT, ANA_OUT, ANA_OUT, ANA_OUT, DIG_OUT,
65 HP_OUT
66};
67static char *const audiophile_meter_labels[] = {
68 ANA_IN, DIG_IN,
69 ANA_OUT, ANA_OUT, DIG_OUT,
70 HP_OUT, AUX_OUT,
71};
72static char *const solo_meter_labels[] = {
73 ANA_IN, DIG_IN,
74 STRM_IN, STRM_IN,
75 ANA_OUT, DIG_OUT
76};
77
78/* no clock info */
79static char *const ozonic_meter_labels[] = {
80 ANA_IN, ANA_IN,
81 STRM_IN, STRM_IN,
82 ANA_OUT, ANA_OUT
83};
84/* TODO: need testers. these positions are based on authour's assumption */
85static char *const nrv10_meter_labels[] = {
86 ANA_IN, ANA_IN, ANA_IN, ANA_IN,
87 DIG_IN,
88 ANA_OUT, ANA_OUT, ANA_OUT, ANA_OUT,
89 DIG_IN
90};
91static int
92normal_meter_get(struct snd_bebob *bebob, u32 *buf, unsigned int size)
93{
94 struct snd_bebob_meter_spec *spec = bebob->spec->meter;
95 unsigned int c, channels;
96 int err;
97
98 channels = spec->num * 2;
99 if (size < channels * sizeof(u32))
100 return -EINVAL;
101
102 err = get_meter(bebob, (void *)buf, size);
103 if (err < 0)
104 goto end;
105
106 for (c = 0; c < channels; c++)
107 be32_to_cpus(&buf[c]);
108
109 /* swap stream channels because inverted */
110 if (spec->labels == solo_meter_labels) {
111 swap(buf[4], buf[6]);
112 swap(buf[5], buf[7]);
113 }
114end:
115 return err;
116}
117
118/* Firewire 410 specification */
119static struct snd_bebob_rate_spec usual_rate_spec = {
120 .get = &snd_bebob_stream_get_rate,
121 .set = &snd_bebob_stream_set_rate,
122};
123static struct snd_bebob_meter_spec fw410_meter_spec = {
124 .num = ARRAY_SIZE(fw410_meter_labels),
125 .labels = fw410_meter_labels,
126 .get = &normal_meter_get
127};
128struct snd_bebob_spec maudio_fw410_spec = {
129 .clock = NULL,
130 .rate = &usual_rate_spec,
131 .meter = &fw410_meter_spec
132};
133
134/* Firewire Audiophile specification */
135static struct snd_bebob_meter_spec audiophile_meter_spec = {
136 .num = ARRAY_SIZE(audiophile_meter_labels),
137 .labels = audiophile_meter_labels,
138 .get = &normal_meter_get
139};
140struct snd_bebob_spec maudio_audiophile_spec = {
141 .clock = NULL,
142 .rate = &usual_rate_spec,
143 .meter = &audiophile_meter_spec
144};
145
146/* Firewire Solo specification */
147static struct snd_bebob_meter_spec solo_meter_spec = {
148 .num = ARRAY_SIZE(solo_meter_labels),
149 .labels = solo_meter_labels,
150 .get = &normal_meter_get
151};
152struct snd_bebob_spec maudio_solo_spec = {
153 .clock = NULL,
154 .rate = &usual_rate_spec,
155 .meter = &solo_meter_spec
156};
157
158/* Ozonic specification */
159static struct snd_bebob_meter_spec ozonic_meter_spec = {
160 .num = ARRAY_SIZE(ozonic_meter_labels),
161 .labels = ozonic_meter_labels,
162 .get = &normal_meter_get
163};
164struct snd_bebob_spec maudio_ozonic_spec = {
165 .clock = NULL,
166 .rate = &usual_rate_spec,
167 .meter = &ozonic_meter_spec
168};
169
170/* NRV10 specification */
171static struct snd_bebob_meter_spec nrv10_meter_spec = {
172 .num = ARRAY_SIZE(nrv10_meter_labels),
173 .labels = nrv10_meter_labels,
174 .get = &normal_meter_get
175};
176struct snd_bebob_spec maudio_nrv10_spec = {
177 .clock = NULL,
178 .rate = &usual_rate_spec,
179 .meter = &nrv10_meter_spec
180};