1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* Copyright (C) 2005-2008 by Jonathan Woithe |
---|
4 |
* |
---|
5 |
* This file is part of FFADO |
---|
6 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
7 |
* |
---|
8 |
* FFADO is based upon FreeBoB. |
---|
9 |
* |
---|
10 |
* This program is free software: you can redistribute it and/or modify |
---|
11 |
* it under the terms of the GNU General Public License as published by |
---|
12 |
* the Free Software Foundation, either version 2 of the License, or |
---|
13 |
* (at your option) version 3 of the License. |
---|
14 |
* |
---|
15 |
* This program is distributed in the hope that it will be useful, |
---|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 |
* GNU General Public License for more details. |
---|
19 |
* |
---|
20 |
* You should have received a copy of the GNU General Public License |
---|
21 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
22 |
* |
---|
23 |
*/ |
---|
24 |
|
---|
25 |
#ifndef MOTUDEVICE_H |
---|
26 |
#define MOTUDEVICE_H |
---|
27 |
|
---|
28 |
#include "ffadodevice.h" |
---|
29 |
|
---|
30 |
#include "debugmodule/debugmodule.h" |
---|
31 |
#include "libavc/avc_definitions.h" |
---|
32 |
|
---|
33 |
#include "libstreaming/motu/MotuReceiveStreamProcessor.h" |
---|
34 |
#include "libstreaming/motu/MotuTransmitStreamProcessor.h" |
---|
35 |
|
---|
36 |
#include "motu_controls.h" |
---|
37 |
#include "motu_mark3_controls.h" |
---|
38 |
|
---|
39 |
/* Bitmasks and values used when setting MOTU device registers. Note that |
---|
40 |
* the only "generation 1" device presently supported is the original 828. |
---|
41 |
* "Generation 2" devices include the original Traveler, the 828Mk2, the |
---|
42 |
* original Ultralite, the 896/896HD and so forth. "Generation 3" devices |
---|
43 |
* are all those which carry the "Mark 3" moniker. |
---|
44 |
*/ |
---|
45 |
#define MOTU_RATE_BASE_44100 (0<<3) |
---|
46 |
#define MOTU_RATE_BASE_48000 (1<<3) |
---|
47 |
#define MOTU_RATE_MULTIPLIER_1X (0<<4) |
---|
48 |
#define MOTU_RATE_MULTIPLIER_2X (1<<4) |
---|
49 |
#define MOTU_RATE_MULTIPLIER_4X (2<<4) |
---|
50 |
#define MOTU_RATE_BASE_MASK (0x00000008) |
---|
51 |
#define MOTU_RATE_MULTIPLIER_MASK (0x00000030) |
---|
52 |
|
---|
53 |
#define MOTU_G2_OPTICAL_MODE_OFF 0x00 |
---|
54 |
#define MOTU_G2_OPTICAL_MODE_ADAT 0x01 |
---|
55 |
#define MOTU_G2_OPTICAL_MODE_TOSLINK 0x02 |
---|
56 |
#define MOTU_G2_OPTICAL_IN_MODE_MASK (0x00000300) |
---|
57 |
#define MOTU_G2_OPTICAL_IN_MODE_BIT0 8 |
---|
58 |
#define MOTU_G2_OPTICAL_OUT_MODE_MASK (0x00000c00) |
---|
59 |
#define MOTU_G2_OPTICAL_OUT_MODE_BIT0 10 |
---|
60 |
#define MOTU_G2_OPTICAL_MODE_MASK (MOTU_G2_OPTICAL_IN_MODE_MASK|MOTU_G2_OPTICAL_MODE_MASK) |
---|
61 |
|
---|
62 |
#define MOTU_G2_CLKSRC_MASK 0x00000007 |
---|
63 |
#define MOTU_G2_CLKSRC_INTERNAL 0 |
---|
64 |
#define MOTU_G2_CLKSRC_ADAT_OPTICAL 1 |
---|
65 |
#define MOTU_G2_CLKSRC_SPDIF_TOSLINK 2 |
---|
66 |
#define MOTU_G2_CLKSRC_SMPTE 3 |
---|
67 |
#define MOTU_G2_CLKSRC_WORDCLOCK 4 |
---|
68 |
#define MOTU_G2_CLKSRC_ADAT_9PIN 5 |
---|
69 |
#define MOTU_G2_CLKSRC_AES_EBU 7 |
---|
70 |
|
---|
71 |
#define MOTU_METER_PEAKHOLD_MASK 0x3800 |
---|
72 |
#define MOTU_METER_PEAKHOLD_SHIFT 11 |
---|
73 |
#define MOTU_METER_CLIPHOLD_MASK 0x0700 |
---|
74 |
#define MOTU_METER_CLIPHOLD_SHIFT 8 |
---|
75 |
#define MOTU_METER_AESEBU_SRC_MASK 0x0004 |
---|
76 |
#define MOTU_METER_AESEBU_SRC_SHIFT 2 |
---|
77 |
#define MOTU_METER_PROG_SRC_MASK 0x0003 |
---|
78 |
#define MOTU_METER_PROG_SRC_SHIFT 0 |
---|
79 |
|
---|
80 |
/* Device registers. The "base" registers (that is, those shared |
---|
81 |
* between the G1, G2 and G3 interfaces) are specified and assumed to |
---|
82 |
* be relative to MOTU_REG_BASE_ADDR. The following block is notionally |
---|
83 |
* for G2 devices, although some of these are shared with G1 and G3 |
---|
84 |
* units too. |
---|
85 |
*/ |
---|
86 |
#define MOTU_REG_BASE_ADDR 0xfffff0000000ULL |
---|
87 |
#define MOTU_REG_ISOCTRL 0x0b00 |
---|
88 |
#define MOTU_REG_OPTICAL_CTRL 0x0b10 |
---|
89 |
#define MOTU_REG_CLK_CTRL 0x0b14 |
---|
90 |
#define MOTU_REG_896HD_METER_REG 0x0b1c |
---|
91 |
#define MOTU_REG_896HD_METER_CONF 0x0b24 |
---|
92 |
#define MOTU_REG_ROUTE_PORT_CONF 0x0c04 |
---|
93 |
#define MOTU_REG_INPUT_LEVEL 0x0c08 |
---|
94 |
#define MOTU_REG_INPUT_BOOST 0x0c14 |
---|
95 |
#define MOTU_REG_INPUT_GAIN_PAD_0 0x0c1c |
---|
96 |
#define MOTU_REG_CLKSRC_NAME0 0x0c60 |
---|
97 |
#define MOTU_REG_INPUT_GAIN_PHINV0 0x0c70 |
---|
98 |
#define MOTU_REG_INPUT_GAIN_PHINV1 0x0c74 |
---|
99 |
#define MOTU_REG_INPUT_GAIN_PHINV2 0x0c78 |
---|
100 |
|
---|
101 |
/* Device register definitions for the earliest generation devices */ |
---|
102 |
#define MOTU_G1_REG_CONFIG 0x0b00 |
---|
103 |
#define MOTU_G1_REG_UNKNOWN_1 0x0b04 // Precise function unknown |
---|
104 |
#define MOTU_G1_REG_UNKNOWN_2 0x0b08 // Precise function unknown |
---|
105 |
#define MOTU_G1_REG_CONFIG_2 0x0b10 |
---|
106 |
|
---|
107 |
/* Values written to registers in G1 devices. |
---|
108 |
* |
---|
109 |
* Control of the optical mode on the G1 devices (such as the 828mk1) is |
---|
110 |
* strange in that it's split across two configration registers. |
---|
111 |
* Furthermore, while the toslink mode is controlled by "enable" bits, the |
---|
112 |
* ADAT mode is controlled by "disable" bits (that is, the mode is active if |
---|
113 |
* the bits are clear. |
---|
114 |
*/ |
---|
115 |
#define MOTU_G1_C1_ISO_ENABLE 0x00000080 |
---|
116 |
#define MOTU_G1_C1_OPT_TOSLINK_IN 0x00008000 |
---|
117 |
#define MOTU_G1_C1_OPT_TOSLINK_OUT 0x00004000 |
---|
118 |
#define MOTU_G1_C1_ISO_TX_CH_MASK 0x000f0000 |
---|
119 |
#define MOTU_G1_C1_ISO_TX_CH_BIT0 16 |
---|
120 |
#define MOTU_G1_C1_ISO_TX_ACTIVE 0x00400000 |
---|
121 |
#define MOTU_G1_C1_ISO_TX_WREN 0x00800000 // Enable iso tx conf changes |
---|
122 |
#define MOTU_G1_C1_ISO_RX_CH_MASK 0x0f000000 |
---|
123 |
#define MOTU_G1_C1_ISO_RX_CH_BIT0 24 |
---|
124 |
#define MOTU_G1_C1_ISO_RX_ACTIVE 0x40000000 |
---|
125 |
#define MOTU_G1_C1_ISO_RX_WREN 0x80000000 // Enable iso rx conf changes |
---|
126 |
#define MOTU_G1_C1_ISO_INFO_MASK 0xffff0000 |
---|
127 |
#define MOTU_G1_C2_OPT_nADAT_IN 0x00000080 |
---|
128 |
#define MOTU_G1_C2_OPT_nADAT_OUT 0x00000040 |
---|
129 |
#define MOTU_G1_C2_OPT_nADAT_WREN 0x00000002 // Purpose to be confirmed |
---|
130 |
|
---|
131 |
// Rate control bits in MOTU_G1_REG_CONFIG |
---|
132 |
#define MOTU_G1_RATE_MASK 0x0004 |
---|
133 |
#define MOTU_G1_RATE_44100 0x0000 |
---|
134 |
#define MOTU_G1_RATE_48000 0x0004 |
---|
135 |
|
---|
136 |
// Clock source control bits in MOTU_G1_REG_CONFIG. The SMTPE clock source |
---|
137 |
// is not presently supported in FFADO because software requirements of this |
---|
138 |
// source are not yet known. |
---|
139 |
#define MOTU_G1_CLKSRC_MASK 0x0023 |
---|
140 |
#define MOTU_G1_CLKSRC_ADAT_9PIN 0x0001 |
---|
141 |
#define MOTU_G1_CLKSRC_SMTPE 0x0003 // Not currently supported in FFADO |
---|
142 |
#define MOTU_G1_CLKSRC_INTERNAL 0x0020 |
---|
143 |
#define MOTU_G1_CLKSRC_SPDIF 0x0022 |
---|
144 |
#define MOTU_G1_CLKSRC_TOSLINK 0x0022 |
---|
145 |
#define MOTU_G1_CLKSRC_ADAT_OPTICAL 0x0021 |
---|
146 |
#define MOTU_G1_CLKSRC_UNCHANGED MOTU_CLKSRC_UNCHANGED |
---|
147 |
|
---|
148 |
// Monitor control bits in MOTU_G1_REG_CONFIG |
---|
149 |
#define MOTU_G1_MONIN_MUTE 0x0040 |
---|
150 |
#define MOTU_G1_MONIN_MASK 0x3f00 |
---|
151 |
#define MOTU_G1_MONIN_L_SRC_MASK 0x0700 |
---|
152 |
#define MOTU_G1_MONIN_R_SRC_MASK 0x3800 |
---|
153 |
#define MOTU_G1_MONIN_L_CH_BIT0 8 |
---|
154 |
#define MOTU_G1_MONIN_R_CH_BIT0 11 |
---|
155 |
#define MOTU_G1_MONIN_L_CH1 0x0000 |
---|
156 |
#define MOTU_G1_MONIN_L_CH2 0x0100 |
---|
157 |
#define MOTU_G1_MONIN_L_CH3 0x0200 |
---|
158 |
#define MOTU_G1_MONIN_L_CH4 0x0300 |
---|
159 |
#define MOTU_G1_MONIN_L_CH5 0x0400 |
---|
160 |
#define MOTU_G1_MONIN_L_CH6 0x0500 |
---|
161 |
#define MOTU_G1_MONIN_L_CH7 0x0600 |
---|
162 |
#define MOTU_G1_MONIN_L_CH8 0x0700 |
---|
163 |
#define MOTU_G1_MONIN_R_CH1 0x0000 |
---|
164 |
#define MOTU_G1_MONIN_R_CH2 0x0800 |
---|
165 |
#define MOTU_G1_MONIN_R_CH3 0x1000 |
---|
166 |
#define MOTU_G1_MONIN_R_CH4 0x1800 |
---|
167 |
#define MOTU_G1_MONIN_R_CH5 0x2000 |
---|
168 |
#define MOTU_G1_MONIN_R_CH6 0x2800 |
---|
169 |
#define MOTU_G1_MONIN_R_CH7 0x3000 |
---|
170 |
#define MOTU_G1_MONIN_R_CH8 0x3800 |
---|
171 |
|
---|
172 |
// Other control bits in MOTU_G1_REG_CONFIG |
---|
173 |
#define MOTU_G1_IO_ENABLE_0 0x0008 // To be confirmed |
---|
174 |
|
---|
175 |
/* Mark3 device registers - these don't always have MOTU_BASE_ADDR as the |
---|
176 |
* base address so for now we'll define them as absolute addresses. The |
---|
177 |
* "Mark 3" (aka G3) devices share a number of control registers with the G2 |
---|
178 |
* devices. Where this occurs we just use the G2 definitions since there's |
---|
179 |
* little to be gained by adding duplicate defines. |
---|
180 |
*/ |
---|
181 |
#define MOTU_G3_REG_MIXER 0xffff00010000ULL |
---|
182 |
#define MOTU_G3_REG_OPTICAL_CTRL 0xfffff0000c94ULL |
---|
183 |
|
---|
184 |
/* Mark3 (aka G3) register constants for cases where the G3 devices differ |
---|
185 |
* from the G2s. |
---|
186 |
*/ |
---|
187 |
#define MOTU_G3_CLKSRC_MASK 0x0000001b |
---|
188 |
#define MOTU_G3_CLKSRC_INTERNAL 0x00000000 |
---|
189 |
#define MOTU_G3_CLKSRC_WORDCLOCK 0x00000001 |
---|
190 |
#define MOTU_G3_CLKSRC_SMPTE 0x00000002 |
---|
191 |
#define MOTU_G3_CLKSRC_SPDIF 0x00000010 |
---|
192 |
#define MOTU_G3_CLKSRC_OPTICAL_A 0x00000018 |
---|
193 |
#define MOTU_G3_CLKSRC_OPTICAL_B 0x00000019 |
---|
194 |
#define MOTU_G3_CLKSRC_ADAT_A MOTU_G3_CLKSRC_OPTICAL_A |
---|
195 |
#define MOTU_G3_CLKSRC_ADAT_B MOTU_G3_CLKSRC_OPTICAL_B |
---|
196 |
#define MOTU_G3_CLKSRC_TOSLINK_A MOTU_G3_CLKSRC_OPTICAL_A |
---|
197 |
#define MOTU_G3_CLKSRC_TOSLINK_B MOTU_G3_CLKSRC_OPTICAL_A |
---|
198 |
|
---|
199 |
#define MOTU_G3_RATE_BASE_44100 (0<<8) |
---|
200 |
#define MOTU_G3_RATE_BASE_48000 (1<<8) |
---|
201 |
#define MOTU_G3_RATE_MULTIPLIER_1X (0<<9) |
---|
202 |
#define MOTU_G3_RATE_MULTIPLIER_2X (1<<9) |
---|
203 |
#define MOTU_G3_RATE_MULTIPLIER_4X (2<<9) |
---|
204 |
#define MOTU_G3_RATE_BASE_MASK (0x00000100) |
---|
205 |
#define MOTU_G3_RATE_MULTIPLIER_MASK (0x00000600) |
---|
206 |
|
---|
207 |
#define MOTU_G3_OPT_A_IN_ENABLE 0x00000001 |
---|
208 |
#define MOTU_G3_OPT_B_IN_ENABLE 0x00000002 |
---|
209 |
#define MOTU_G3_OPT_A_OUT_ENABLE 0x00000100 |
---|
210 |
#define MOTU_G3_OPT_B_OUT_ENABLE 0x00000200 |
---|
211 |
#define MOTU_G3_OPT_A_IN_TOSLINK 0x00010000 // If these mode bits are not |
---|
212 |
#define MOTU_G3_OPT_A_OUT_TOSLINK 0x00040000 // set the mode is ADAT if |
---|
213 |
#define MOTU_G3_OPT_B_IN_TOSLINK 0x00100000 // the port is enabled |
---|
214 |
#define MOTU_G3_OPT_B_OUT_TOSLINK 0x00400000 |
---|
215 |
#define MOTU_G3_OPT_A_IN_MASK (MOTU_G3_OPT_A_IN_ENABLE|MOTU_G3_OPT_A_IN_TOSLINK) |
---|
216 |
#define MOTU_G3_OPT_A_OUT_MASK (MOTU_G3_OPT_A_OUT_ENABLE|MOTU_G3_OPT_A_OUT_TOSLINK) |
---|
217 |
#define MOTU_G3_OPT_B_IN_MASK (MOTU_G3_OPT_B_IN_ENABLE|MOTU_G3_OPT_B_IN_TOSLINK) |
---|
218 |
#define MOTU_G3_OPT_B_OUT_MASK (MOTU_G3_OPT_B_OUT_ENABLE|MOTU_G3_OPT_B_OUT_TOSLINK) |
---|
219 |
|
---|
220 |
/* The following values are used when defining configuration structures and |
---|
221 |
* calling driver functions. They are generally not raw values written to |
---|
222 |
* registers. |
---|
223 |
*/ |
---|
224 |
|
---|
225 |
/* Port Active Flags (ports declaration) */ |
---|
226 |
#define MOTU_PA_RATE_1x 0x0001 /* 44k1 or 48k */ |
---|
227 |
#define MOTU_PA_RATE_2x 0x0002 /* 88k2 or 96k */ |
---|
228 |
#define MOTU_PA_RATE_4x 0x0004 /* 176k4 or 192k */ |
---|
229 |
#define MOTU_PA_RATE_1x2x (MOTU_PA_RATE_1x|MOTU_PA_RATE_2x) |
---|
230 |
#define MOTU_PA_RATE_2x4x (MOTU_PA_RATE_2x|MOTU_PA_RATE_4x) |
---|
231 |
#define MOTU_PA_RATE_ANY (MOTU_PA_RATE_1x|MOTU_PA_RATE_2x|MOTU_PA_RATE_4x) |
---|
232 |
#define MOTU_PA_RATE_MASK MOTU_PA_RATE_ANY |
---|
233 |
#define MOTU_PA_OPTICAL_OFF 0x0010 /* Optical port off */ |
---|
234 |
#define MOTU_PA_OPTICAL_ADAT 0x0020 /* Optical port in ADAT mode */ |
---|
235 |
#define MOTU_PA_OPTICAL_TOSLINK 0x0040 /* Optical port in SPDIF/Toslink mode */ |
---|
236 |
#define MOTU_PA_OPTICAL_ON (MOTU_PA_OPTICAL_ADAT|MOTU_PA_OPTICAL_TOSLINK) |
---|
237 |
#define MOTU_PA_OPTICAL_ANY (MOTU_PA_OPTICAL_OFF|MOTU_PA_OPTICAL_ON) |
---|
238 |
#define MOTU_PA_OPTICAL_MASK MOTU_PA_OPTICAL_ANY |
---|
239 |
#define MOTU_PA_PADDING 0x0100 |
---|
240 |
#define MOTU_PA_IN 0x0200 |
---|
241 |
#define MOTU_PA_OUT 0x0400 |
---|
242 |
#define MOTU_PA_INOUT (MOTU_PA_IN | MOTU_PA_OUT) |
---|
243 |
/* The Mark3 devices have two optical ports */ |
---|
244 |
#define MOTU_PA_MK3_OPT_A_OFF MOTU_PA_OPTICAL_OFF |
---|
245 |
#define MOTU_PA_MK3_OPT_A_ADAT MOTU_PA_OPTICAL_ADAT |
---|
246 |
#define MOTU_PA_MK3_OPT_A_TOSLINK MOTU_PA_OPTICAL_TOSLINK |
---|
247 |
#define MOTU_PA_MK3_OPT_A_ON (MOTU_PA_MK3_OPT_A_ADAT|MOTU_PA_MK3_OPT_A_TOSLINK) |
---|
248 |
#define MOTU_PA_MK3_OPT_A_ANY (MOTU_PA_MK3_OPT_A_OFF|MOTU_PA_MK3_OPT_A_ON) |
---|
249 |
#define MOTU_PA_MK3_OPT_A_MASK MOTU_PA_MK3_OPT_A_ANY |
---|
250 |
#define MOTU_PA_MK3_OPT_B_OFF 0x1000 |
---|
251 |
#define MOTU_PA_MK3_OPT_B_ADAT 0x2000 |
---|
252 |
#define MOTU_PA_MK3_OPT_B_TOSLINK 0x4000 |
---|
253 |
#define MOTU_PA_MK3_OPT_B_ON (MOTU_PA_MK3_OPT_B_ADAT|MOTU_PA_MK3_OPT_B_TOSLINK) |
---|
254 |
#define MOTU_PA_MK3_OPT_B_ANY (MOTU_PA_MK3_OPT_B_OFF|MOTU_PA_MK3_OPT_B_ON) |
---|
255 |
#define MOTU_PA_MK3_OPT_B_MASK MOTU_PA_MK3_OPT_B_ANY |
---|
256 |
#define MOTU_PA_MK3_OPT_ANY (MOTU_PA_MK3_OPT_A_ANY|MOTU_PA_MK3_OPT_B_ANY) |
---|
257 |
|
---|
258 |
/* Generic "direction" flags */ |
---|
259 |
#define MOTU_DIR_IN 1 |
---|
260 |
#define MOTU_DIR_OUT 2 |
---|
261 |
#define MOTU_DIR_INOUT (MOTU_DIR_IN | MOTU_DIR_OUT) |
---|
262 |
|
---|
263 |
/* Optical port mode settings/flags */ |
---|
264 |
#define MOTU_OPTICAL_MODE_OFF 0x0000 |
---|
265 |
#define MOTU_OPTICAL_MODE_ADAT 0x0001 |
---|
266 |
#define MOTU_OPTICAL_MODE_TOSLINK 0x0002 |
---|
267 |
#define MOTU_OPTICAL_MODE_KEEP 0xffff |
---|
268 |
#define MOTU_OPTICAL_MODE_NONE 0xffffffff |
---|
269 |
|
---|
270 |
/* Clock source settings/flags */ |
---|
271 |
#define MOTU_CLKSRC_INTERNAL 0 |
---|
272 |
#define MOTU_CLKSRC_ADAT_OPTICAL 1 |
---|
273 |
#define MOTU_CLKSRC_SPDIF_TOSLINK 2 |
---|
274 |
#define MOTU_CLKSRC_SMPTE 3 |
---|
275 |
#define MOTU_CLKSRC_WORDCLOCK 4 |
---|
276 |
#define MOTU_CLKSRC_ADAT_9PIN 5 |
---|
277 |
#define MOTU_CLKSRC_AES_EBU 6 |
---|
278 |
#define MOTU_CLKSRC_OPTICAL_A 7 |
---|
279 |
#define MOTU_CLKSRC_OPTICAL_B 8 |
---|
280 |
#define MOTU_CLKSRC_LAST 8 |
---|
281 |
#define MOTU_CLKSRC_NONE 0xffff |
---|
282 |
#define MOTU_CLKSRC_UNCHANGED MOTU_CLKSRC_NONE |
---|
283 |
|
---|
284 |
/* Device generation identifiers */ |
---|
285 |
#define MOTU_DEVICE_G1 0x0001 |
---|
286 |
#define MOTU_DEVICE_G2 0x0002 |
---|
287 |
#define MOTU_DEVICE_G3 0x0003 |
---|
288 |
|
---|
289 |
class ConfigRom; |
---|
290 |
class Ieee1394Service; |
---|
291 |
|
---|
292 |
namespace Util { |
---|
293 |
class Configuration; |
---|
294 |
} |
---|
295 |
|
---|
296 |
namespace Motu { |
---|
297 |
|
---|
298 |
enum EMotuModel { |
---|
299 |
MOTU_MODEL_NONE = 0x0000, |
---|
300 |
MOTU_MODEL_828mkII = 0x0001, |
---|
301 |
MOTU_MODEL_TRAVELER = 0x0002, |
---|
302 |
MOTU_MODEL_ULTRALITE = 0x0003, |
---|
303 |
MOTU_MODEL_8PRE = 0x0004, |
---|
304 |
MOTU_MODEL_828MkI = 0x0005, |
---|
305 |
MOTU_MODEL_896HD = 0x0006, |
---|
306 |
MOTU_MODEL_828mk3 = 0x0007, |
---|
307 |
MOTU_MODEL_ULTRALITEmk3 = 0x0008, |
---|
308 |
MOTU_MODEL_ULTRALITEmk3_HYB = 0x0009, |
---|
309 |
MOTU_MODEL_TRAVELERmk3 = 0x000a, // Placeholder only at present |
---|
310 |
MOTU_MODEL_896mk3 = 0x000b, // Placeholder only at present |
---|
311 |
MOTU_MODEL_4PRE = 0x000c, |
---|
312 |
}; |
---|
313 |
|
---|
314 |
struct VendorModelEntry { |
---|
315 |
unsigned int vendor_id; |
---|
316 |
unsigned int model_id; |
---|
317 |
unsigned int unit_version; |
---|
318 |
unsigned int unit_specifier_id; |
---|
319 |
enum EMotuModel model; |
---|
320 |
const char *vendor_name; |
---|
321 |
const char *model_name; |
---|
322 |
}; |
---|
323 |
|
---|
324 |
struct PortGroupEntry { |
---|
325 |
const char *group_name_format; |
---|
326 |
signed int n_channels; |
---|
327 |
unsigned int flags; |
---|
328 |
signed int port_order; |
---|
329 |
signed int port_num_offset; |
---|
330 |
signed int group_pkt_offset[2]; |
---|
331 |
}; |
---|
332 |
|
---|
333 |
// Structures used for pre-Mark3 device mixer definitions |
---|
334 |
struct MixerCtrl { |
---|
335 |
const char *name, *label, *desc; |
---|
336 |
unsigned int type; |
---|
337 |
unsigned int dev_register; |
---|
338 |
}; |
---|
339 |
struct MatrixMixBus { |
---|
340 |
const char *name; |
---|
341 |
unsigned int address; |
---|
342 |
}; |
---|
343 |
struct MatrixMixChannel { |
---|
344 |
const char *name; |
---|
345 |
unsigned int flags; |
---|
346 |
unsigned int addr_ofs; |
---|
347 |
}; |
---|
348 |
struct MotuMixer { |
---|
349 |
const MixerCtrl *mixer_ctrl; |
---|
350 |
unsigned int n_mixer_ctrls; |
---|
351 |
const MatrixMixBus *mixer_buses; |
---|
352 |
unsigned int n_mixer_buses; |
---|
353 |
const MatrixMixChannel *mixer_channels; |
---|
354 |
unsigned int n_mixer_channels; |
---|
355 |
}; |
---|
356 |
|
---|
357 |
// Structures used for devices which use the "Mark3" mixer protocol |
---|
358 |
struct MotuMark3Mixer { |
---|
359 |
}; |
---|
360 |
|
---|
361 |
struct DevicePropertyEntry { |
---|
362 |
PortGroupEntry *portgroup_entry; |
---|
363 |
unsigned int n_portgroup_entries; |
---|
364 |
signed int MaxSampleRate; |
---|
365 |
// A device will set at most one of the *mixer fields |
---|
366 |
const struct MotuMixer *mixer; |
---|
367 |
const struct MotuMark3Mixer *m3mixer; |
---|
368 |
// Others features can be added here like MIDI port presence. |
---|
369 |
}; |
---|
370 |
|
---|
371 |
extern const DevicePropertyEntry DevicesProperty[]; |
---|
372 |
|
---|
373 |
/* Macro to calculate the size of an array */ |
---|
374 |
#define N_ELEMENTS(_array) (sizeof(_array) / sizeof((_array)[0])) |
---|
375 |
|
---|
376 |
/* Macro to define a MotuMixer structure succintly */ |
---|
377 |
#define MOTUMIXER(_ctrls, _buses, _channels) \ |
---|
378 |
{ _ctrls, N_ELEMENTS(_ctrls), _buses, N_ELEMENTS(_buses), _channels, N_ELEMENTS(_channels), } |
---|
379 |
|
---|
380 |
class MotuDevice : public FFADODevice { |
---|
381 |
public: |
---|
382 |
|
---|
383 |
MotuDevice( DeviceManager& d, ffado_smartptr<ConfigRom>( configRom ) ); |
---|
384 |
virtual ~MotuDevice(); |
---|
385 |
|
---|
386 |
virtual bool buildMixer(); |
---|
387 |
virtual bool destroyMixer(); |
---|
388 |
|
---|
389 |
static bool probe( Util::Configuration&, ConfigRom& configRom, bool generic = false ); |
---|
390 |
static FFADODevice * createDevice( DeviceManager& d, ffado_smartptr<ConfigRom>( configRom )); |
---|
391 |
static int getConfigurationId( ); |
---|
392 |
virtual bool discover(); |
---|
393 |
|
---|
394 |
virtual void showDevice(); |
---|
395 |
|
---|
396 |
unsigned int getHwClockSource(); |
---|
397 |
bool setClockCtrlRegister(signed int samplingFrequency, unsigned int clock_source); |
---|
398 |
virtual bool setSamplingFrequency( int samplingFrequency ); |
---|
399 |
virtual int getSamplingFrequency( ); |
---|
400 |
virtual std::vector<int> getSupportedSamplingFrequencies(); |
---|
401 |
|
---|
402 |
FFADODevice::ClockSource clockIdToClockSource(unsigned int id); |
---|
403 |
virtual ClockSourceVector getSupportedClockSources(); |
---|
404 |
virtual bool setActiveClockSource(ClockSource); |
---|
405 |
virtual ClockSource getActiveClockSource(); |
---|
406 |
|
---|
407 |
virtual int getStreamCount(); |
---|
408 |
virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); |
---|
409 |
virtual enum FFADODevice::eStreamingState getStreamingState(); |
---|
410 |
|
---|
411 |
virtual bool prepare(); |
---|
412 |
virtual bool lock(); |
---|
413 |
virtual bool unlock(); |
---|
414 |
|
---|
415 |
virtual bool startStreamByIndex(int i); |
---|
416 |
virtual bool stopStreamByIndex(int i); |
---|
417 |
|
---|
418 |
signed int getDeviceGeneration(void); |
---|
419 |
|
---|
420 |
signed int getIsoRecvChannel(void); |
---|
421 |
signed int getIsoSendChannel(void); |
---|
422 |
unsigned int getOpticalMode(unsigned int dir, unsigned int *port_a_mode, |
---|
423 |
unsigned int *port_b_mode); |
---|
424 |
signed int setOpticalMode(unsigned int dir, |
---|
425 |
unsigned int port_a_mode, unsigned int port_b_mode); |
---|
426 |
|
---|
427 |
signed int getEventSize(unsigned int dir); |
---|
428 |
|
---|
429 |
signed int m_motu_model; |
---|
430 |
protected: |
---|
431 |
struct VendorModelEntry * m_model; |
---|
432 |
signed int m_iso_recv_channel, m_iso_send_channel; |
---|
433 |
signed int m_rx_bandwidth, m_tx_bandwidth; |
---|
434 |
|
---|
435 |
signed int m_rx_event_size, m_tx_event_size; |
---|
436 |
|
---|
437 |
Streaming::MotuReceiveStreamProcessor *m_receiveProcessor; |
---|
438 |
Streaming::MotuTransmitStreamProcessor *m_transmitProcessor; |
---|
439 |
|
---|
440 |
private: |
---|
441 |
bool buildMixerAudioControls(void); |
---|
442 |
bool buildMark3MixerAudioControls(void); |
---|
443 |
bool addPort(Streaming::StreamProcessor *s_processor, |
---|
444 |
char *name, |
---|
445 |
enum Streaming::Port::E_Direction direction, |
---|
446 |
int position, int size); |
---|
447 |
bool addDirPorts( |
---|
448 |
enum Streaming::Port::E_Direction direction, unsigned int sample_rate, |
---|
449 |
unsigned int optical_a_mode, unsigned int optical_b_mode); |
---|
450 |
bool initDirPortGroups( |
---|
451 |
enum Streaming::Port::E_Direction direction, unsigned int sample_rate, |
---|
452 |
unsigned int optical_a_mode, unsigned int optical_b_mode); |
---|
453 |
bool addDirPortGroups( |
---|
454 |
enum Streaming::Port::E_Direction direction, unsigned int sample_rate, |
---|
455 |
unsigned int optical_a_mode, unsigned int optical_b_mode); |
---|
456 |
|
---|
457 |
public: |
---|
458 |
unsigned int ReadRegister(fb_nodeaddr_t reg); |
---|
459 |
signed int readBlock(fb_nodeaddr_t reg, quadlet_t *buf, signed int n_quads); |
---|
460 |
signed int WriteRegister(fb_nodeaddr_t reg, quadlet_t data); |
---|
461 |
signed int writeBlock(fb_nodeaddr_t reg, quadlet_t *data, signed int n_quads); |
---|
462 |
|
---|
463 |
private: |
---|
464 |
Control::Container *m_MixerContainer; |
---|
465 |
Control::Container *m_ControlContainer; |
---|
466 |
}; |
---|
467 |
|
---|
468 |
} |
---|
469 |
|
---|
470 |
#endif |
---|