1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
use super::Dac;
use crate::routing::{
ControlKey, RouteEdit, RouteReport, RouteValue, RoutingSessionError, RoutingSnapshot,
};
use crate::transport::routing_hw;
/// Unavailable in this release; retained for source compatibility.
///
impl Dac {
/// Discover source-backed DJM choices on an exact, idle vendor PCM session.
/// Discovery leaves the mixer's routing intact.
pub fn djm_routing_discover(
&self,
) -> Result<crate::pioneer::DjmRoutingProfile, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::djm_discover(&self.shared)
}
/// Unavailable in this release; retained for source compatibility.
///
/// Send one explicitly selected DJM option after fresh model, configuration,
/// claim and idle-alternate proof. `option` is a listed zero-based option ID.
/// Success confirms USB acknowledgement. The mixer's current routing
/// remains unknown through this protocol.
pub fn djm_routing_apply(
&self,
model: crate::pioneer::DjmModel,
configuration: u8,
key: crate::pioneer::DjmControlKey,
option: u8,
) -> Result<(), RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::djm_apply(&self.shared, model, configuration, key, option)
}
/// Unavailable in this release; retained for source compatibility.
///
/// Read source-backed first-generation Focusrite controls using the already
/// claimed AudioControl interface while idle. No vendor claim or probe write.
/// Hardware behavior remains physically unvalidated.
pub fn scarlett_gen1_read(&self) -> Result<crate::scarlett::Gen1Readback, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_gen1_read()
}
/// Unavailable in this release; retained for source compatibility.
///
/// Apply bounded typed Gen1 controls against a fresh readback on the live DAC.
/// Verify each write and restore attempted controls on failure. Configured
/// hand-back preserves external edits; no clock, preamp or persistent writes.
pub fn scarlett_gen1_apply(
&self,
expected: &crate::scarlett::Gen1Readback,
edits: &[crate::scarlett::Gen1Edit],
) -> Result<crate::scarlett::Gen1Report, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_gen1_apply(expected, edits)
}
/// Unavailable in this release; retained for source compatibility.
///
/// Inspect the exact Scarlett read candidate and required vendor claim,
/// without initializing its protocol or reading proprietary state.
pub fn scarlett_routing_capability(
&self,
) -> Result<Option<crate::scarlett::ReadCapability>, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_discover()
}
/// Unavailable in this release; retained for source compatibility.
///
/// Initialize and read source-backed Scarlett routing while idle. Requires
/// the host's explicit vendor-interface claim. Exact-model firmware and live geometry
/// guards apply before mux/mix controls become available. No route, volume or persistent setting
/// writes are sent. Hardware behavior remains unvalidated.
pub fn scarlett_routing_read(
&self,
) -> Result<crate::scarlett::RoutingReadback, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_read()
}
/// Unavailable in this release; retained for source compatibility.
///
/// Read firmware-defined modern Focusrite FCP pins, mux banks and mix rows.
/// Requires idle ownership and an explicit exact-model vendor-interface claim.
/// Does not send persistent configuration commands.
pub fn fcp_routing_read(&self) -> Result<crate::scarlett::FcpReadback, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::fcp_read()
}
/// Unavailable in this release; retained for source compatibility.
///
/// Apply typed firmware pin routes and mixer coefficients against a fresh readback.
/// Requires idle ownership and explicit vendor claim. Verify every affected target,
/// restore attempted targets on failure, and preserve external edits at hand-back.
/// No persistent configuration commands are sent. Physically unvalidated.
pub fn fcp_routing_apply(
&self,
expected: &crate::scarlett::FcpReadback,
routes: &[crate::scarlett::FcpRouteEdit],
mixes: &[crate::scarlett::FcpMixEdit],
) -> Result<crate::scarlett::FcpWriteReport, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::fcp_apply(expected, routes, mixes)
}
/// Unavailable in this release; retained for source compatibility.
///
/// Apply bounded half-dB replacements to one complete Scarlett mixer row.
/// Requires fresh expected raw coefficients, idle ownership and the explicit
/// vendor claim. Verifies the whole row and attempts verified restoration
/// after any attempted-write failure. Configured hand-back restores only
/// rows still matching the last verified write. Source-backed, physically
/// unverified; no mux bank or persistent configuration is written.
pub fn scarlett_mix_apply(
&self,
edit: &crate::scarlett::MixRowEdit,
) -> Result<crate::scarlett::MixWriteReport, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_mix_apply(edit)
}
/// Unavailable in this release; retained for source compatibility.
///
/// Probe optional per-bank support and read every raw bank including padding.
/// An unsupported response never enables writes; legacy reads remain usable.
pub fn scarlett_mux_read(&self) -> Result<crate::scarlett::MuxSnapshot, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_mux_read()
}
/// Unavailable in this release; retained for source compatibility.
///
/// Apply explicit bank edits only after a fresh complete capability/geometry
/// read equals the expected snapshot. Restore each attempted raw bank after
/// any uncertain write. Configured hand-back preserves external edits.
/// Source-backed; physical routing has not been validated.
pub fn scarlett_mux_apply(
&self,
edit: &crate::scarlett::MuxEdit,
) -> Result<crate::scarlett::MuxWriteReport, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::scarlett_mux_apply(edit)
}
/// Discover standard UAC2 selectors and mixer crosspoints on claimed
/// AudioControl interfaces in the active configuration. No vendor protocol
/// is inferred. Requires an idle DAC, including no open capture stream.
pub fn routing_discover(&self) -> Result<RoutingSnapshot, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::discover()
}
/// Explicitly wake affected full ADC3 routing domains on entirely claimed
/// idle functions. Restore checked original power after discovery, including
/// failures. The snapshot does not retain a power lease.
pub fn routing_discover_powered(&self) -> Result<RoutingSnapshot, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::discover_with_power(true)
}
/// Revalidate the snapshot and acquire a fresh scoped ADC3 routing lease.
/// Preserve external power drift instead of overwriting it on hand-back.
pub fn routing_read_powered(
&self,
snapshot: &RoutingSnapshot,
key: ControlKey,
) -> Result<RouteValue, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::read_with_power(snapshot, key, true)
}
/// Apply the ordinary verified routing transaction with explicit scoped
/// ADC3 wake. Restore original power after success or failure. Configured
/// route hand-back reacquires power only for these opted-in edits.
pub fn routing_apply_powered(
&self,
snapshot: &RoutingSnapshot,
edits: &[RouteEdit],
) -> Result<RouteReport, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::apply_with_power(snapshot, edits, true)
}
/// Read a descriptor-backed control after checking the attachment,
/// configuration, descriptors and discovered selector pins for drift.
pub fn routing_read(
&self,
snapshot: &RoutingSnapshot,
key: ControlKey,
) -> Result<RouteValue, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::read(snapshot, key)
}
/// Apply bounded, verified routing edits only while idle. Each edit includes
/// the expected current value from `routing_read`; stale values fail before
/// writing. Rediscover after changing a selector. The configured HandBack
/// policy controls route restoration on close; `close_with` overrides volume
/// handling only. Feature Unit volume and mute settings are not changed.
pub fn routing_apply(
&self,
snapshot: &RoutingSnapshot,
edits: &[RouteEdit],
) -> Result<RouteReport, RoutingSessionError> {
let _control = self
.shared
.control_guard
.try_lock()
.ok_or(RoutingSessionError::Session(crate::Error::Busy))?;
self.shared
.reject_reconfigure()
.map_err(RoutingSessionError::Session)?;
let _scope = self.shared.enter().map_err(RoutingSessionError::Session)?;
routing_hw::apply(snapshot, edits)
}
}