firewire_bebob_protocols/
icon.rs

1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (c) 2021 Takashi Sakamoto
3
4//! Protocol implementation for models of Icon Digital International.
5//!
6//! The module includes structure, enumeration, and trait and its implementation for protocol
7//! defined by Icon for FireWire models.
8//!
9
10//! ## Diagram of internal signal flow for Firexon
11//!
12//! ```text
13//! analog-input-1/2 --------+------------------------------> stream-output-1/2
14//! analog-input-3/4 --------|-+----------------------------> stream-output-3/4
15//! digital-input-1/2 -------|-|-+--------------------------> stream-output-5/6
16//!                          | | |
17//!                          v v v
18//!                      ++=========++
19//!                      ||  6 x 2  ||
20//!                      || monitor ||
21//!                      ++=========++
22//!                            |
23//!                            v              ++=======++
24//!                    monitor-output-1/2 --> || 4 x 2 ||
25//!                                           || mixer ||
26//!                            +------------> ||       ||
27//!                            |              ++=======++
28//!                            |                   |
29//!                            |            mixer-output-1/2
30//!                            |                  | |
31//! stream-input-1/2 ----------+                  | +-------> analog-output-1/2
32//!                                               v
33//! stream-input-3/4 ---------------------(one source only)-> analog-output-3/4
34//!                                               ^
35//! stream-input-5/6 -----------------------------+---------> digital-output-1/2
36//! ```
37
38use super::*;
39
40/// The protocol implementation of clock operation.
41#[derive(Default, Debug)]
42pub struct FirexonClkProtocol;
43
44impl MediaClockFrequencyOperation for FirexonClkProtocol {
45    const FREQ_LIST: &'static [u32] = &[44100, 48000, 88200, 96000, 176400, 192000];
46}
47
48impl SamplingClockSourceOperation for FirexonClkProtocol {
49    const DST: SignalAddr = SignalAddr::Subunit(SignalSubunitAddr {
50        subunit: MUSIC_SUBUNIT_0,
51        plug_id: 0x05,
52    });
53
54    const SRC_LIST: &'static [SignalAddr] = &[
55        // Internal.
56        SignalAddr::Subunit(SignalSubunitAddr {
57            subunit: MUSIC_SUBUNIT_0,
58            plug_id: 0x05,
59        }),
60        // S/PDIF in coaxial interface.
61        SignalAddr::Unit(SignalUnitAddr::Ext(0x03)),
62    ];
63}
64
65/// The protocol implementation of physical output.
66#[derive(Default, Debug)]
67pub struct FirexonPhysOutputProtocol;
68
69impl AvcAudioFeatureSpecification for FirexonPhysOutputProtocol {
70    const ENTRIES: &'static [(u8, AudioCh)] = &[
71        (0x06, AudioCh::Each(0)), // analog-output-1
72        (0x06, AudioCh::Each(1)), // analog-output-2
73        (0x07, AudioCh::Each(0)), // analog-output-3
74        (0x07, AudioCh::Each(1)), // analog-output-4
75    ];
76}
77
78impl AvcLevelOperation for FirexonPhysOutputProtocol {}
79
80impl AvcLrBalanceOperation for FirexonPhysOutputProtocol {}
81
82impl AvcMuteOperation for FirexonPhysOutputProtocol {}
83
84impl AvcSelectorOperation for FirexonPhysOutputProtocol {
85    // NOTE: "analog-output-3/4" (not "analog-output-1/2")
86    const FUNC_BLOCK_ID_LIST: &'static [u8] = &[0x01];
87    // NOTE: "mixer-output-1/2", "stream-input-3/4", "stream-input-5/6"
88    const INPUT_PLUG_ID_LIST: &'static [u8] = &[0x00, 0x01, 0x02];
89}
90
91/// The protocol implementation of source to monitor mixer for physical inputs
92#[derive(Default, Debug)]
93pub struct FirexonMonitorSourceProtocol;
94
95impl AvcAudioFeatureSpecification for FirexonMonitorSourceProtocol {
96    const ENTRIES: &'static [(u8, AudioCh)] = &[
97        (0x01, AudioCh::Each(0)), // analog-input-1
98        (0x01, AudioCh::Each(1)), // analog-input-2
99        (0x02, AudioCh::Each(0)), // analog-input-3
100        (0x02, AudioCh::Each(1)), // analog-input-4
101        (0x03, AudioCh::Each(0)), // digital-input-5
102        (0x03, AudioCh::Each(1)), // digital-input-6
103    ];
104}
105
106impl AvcLevelOperation for FirexonMonitorSourceProtocol {}
107
108impl AvcLrBalanceOperation for FirexonMonitorSourceProtocol {}
109
110impl AvcMuteOperation for FirexonMonitorSourceProtocol {}
111
112/// The protocol implementation of source to mixer for stream input and output of the monitor mixer.
113#[derive(Default, Debug)]
114pub struct FirexonMixerSourceProtocol;
115
116impl AvcAudioFeatureSpecification for FirexonMixerSourceProtocol {
117    const ENTRIES: &'static [(u8, AudioCh)] = &[
118        (0x04, AudioCh::Master), // stream-input-1/2
119        (0x05, AudioCh::Master), // monitor-output-1/2
120    ];
121}
122
123impl AvcLevelOperation for FirexonMixerSourceProtocol {}