firewire_bebob_protocols/stanton.rs
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (c) 2021 Takashi Sakamoto
3
4//! Protocol implementation for Stanton Magnetics Final Scratch 2 ScratchAmp.
5//!
6//! The module includes structure, enumeration, and trait and its implementation for protocol
7//! defined by Stanton Magnetics for Final Scratch 2 ScratchAmp.
8//!
9//! DM1000E is used for Stanton Scratchamp.
10//!
11//! ## Diagram of internal signal flow
12//!
13//! ```text
14//! analog-input-1/2 -----------------> stream-output-1/2
15//! analog-input-3/4 -----------------> stream-output-3/4
16//! analog-input-5/6 -----------------> stream-output-5/6
17//!
18//! stream-input-1/2 -----------------> analog-output-1/2
19//! stream-input-3/4 -----------------> analog-output-3/4
20//! stream-input-5/6 -----------------> headphone-1/2
21//! ```
22//!
23//! The protocol implementation for Stanton Scratchamp was written with firmware version below:
24//!
25//! ```sh
26//! $ cargo run --bin bco-bootloader-info -- /dev/fw1
27//! protocol:
28//! version: 1
29//! bootloader:
30//! timestamp: 2004-10-06T10:07:36+0000
31//! version: 0.0.0
32//! hardware:
33//! GUID: 0x1000000000126000
34//! model ID: 0x000001
35//! revision: 0.0.3
36//! software:
37//! timestamp: 2004-01-01T12:00:00+0000
38//! ID: 0x00000000
39//! revision: 0.0.0
40//! image:
41//! base address: 0x0
42//! maximum size: 0x120000
43//! ```
44
45use super::*;
46
47/// The protocol implementation for media and sampling clock of Scratchamp.
48#[derive(Default, Debug)]
49pub struct ScratchampClkProtocol;
50
51impl MediaClockFrequencyOperation for ScratchampClkProtocol {
52 const FREQ_LIST: &'static [u32] = &[44100, 48000, 88200, 96000];
53}
54
55impl SamplingClockSourceOperation for ScratchampClkProtocol {
56 const DST: SignalAddr = SignalAddr::Subunit(SignalSubunitAddr {
57 subunit: MUSIC_SUBUNIT_0,
58 plug_id: 0x05,
59 });
60
61 const SRC_LIST: &'static [SignalAddr] = &[
62 // Internal
63 SignalAddr::Subunit(SignalSubunitAddr {
64 subunit: MUSIC_SUBUNIT_0,
65 plug_id: 0x05,
66 }),
67 ];
68}
69
70/// The protocol implementation for physical output of Scratchamp.
71#[derive(Default, Debug)]
72pub struct ScratchampOutputProtocol;
73
74impl AvcAudioFeatureSpecification for ScratchampOutputProtocol {
75 const ENTRIES: &'static [(u8, AudioCh)] = &[
76 (0x01, AudioCh::Each(0)), // analog-output-1
77 (0x01, AudioCh::Each(1)), // analog-output-2
78 (0x02, AudioCh::Each(0)), // analog-output-3
79 (0x02, AudioCh::Each(1)), // analog-output-4
80 ];
81}
82
83impl AvcLevelOperation for ScratchampOutputProtocol {}
84
85/// The protocol implementation for headphone output of Scratchamp.
86#[derive(Default, Debug)]
87pub struct ScratchampHeadphoneProtocol;
88
89impl AvcAudioFeatureSpecification for ScratchampHeadphoneProtocol {
90 const ENTRIES: &'static [(u8, AudioCh)] = &[
91 (0x03, AudioCh::Each(0)), // headphone-1
92 (0x03, AudioCh::Each(1)), // headphone-2
93 ];
94}
95
96impl AvcLevelOperation for ScratchampHeadphoneProtocol {}