2 * Copyright (C) 2013 by Takashi Sakamoto
3 * Copyright (C) 2005-2008 by Pieter Palmers
5 * This file is part of FFADO
6 * FFADO = Free Firewire (pro-)audio drivers for linux
8 * FFADO is based upon FreeBoB.
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.
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.
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/>.
25 #include "firebox_avdevice.h"
31 Device::Device(DeviceManager
& d
, std::auto_ptr
<ConfigRom
>(configRom
))
32 : BeBoB::Device( d
, configRom
)
34 m_intl_clksrc
.type
= FFADODevice::eCT_Internal
;
35 m_intl_clksrc
.valid
= true;
36 m_intl_clksrc
.locked
= true;
37 m_intl_clksrc
.id
= 0x00;
38 m_intl_clksrc
.slipping
= false;
39 m_intl_clksrc
.description
= "Internal";
41 m_spdif_clksrc
.type
= FFADODevice::eCT_SPDIF
;
42 m_spdif_clksrc
.valid
= true;
43 m_spdif_clksrc
.locked
= true;
44 m_spdif_clksrc
.id
= 0x01;
45 m_spdif_clksrc
.slipping
= false;
46 m_spdif_clksrc
.description
= "S/PDIF (Coaxial)";
48 debugOutput( DEBUG_LEVEL_VERBOSE
, "Created BeBoB::Presonus::Firebox::Device (NodeID %d)\n",
49 getConfigRom().getNodeId() );
59 debugOutput(DEBUG_LEVEL_NORMAL
, "This is a BeBoB::Presonus::Firebox::Device\n");
60 BeBoB::Device::showDevice();
63 FFADODevice::ClockSourceVector
64 Device::getSupportedClockSources()
66 FFADODevice::ClockSourceVector r
;
67 r
.push_back(m_intl_clksrc
);
68 r
.push_back(m_spdif_clksrc
);
72 enum FFADODevice::eClockSourceType
75 AVC::SignalSourceCmd
cmd(get1394Service());
76 cmd
.setCommandType(AVC::AVCCommand::eCT_Status
);
77 cmd
.setNodeId(getNodeId());
78 cmd
.setSubunitType(AVC::eST_Unit
);
79 cmd
.setSubunitId(0xff);
80 cmd
.setVerbose(getDebugLevel());
82 AVC::SignalSubunitAddress dst
;
83 dst
.m_subunitType
= AVC::eST_Music
;
84 dst
.m_subunitId
= 0x00;
86 cmd
.setSignalDestination(dst
);
89 debugError( "Signal source command failed\n" );
92 AVC::SignalAddress
* pSyncPlugSignalAddress
= cmd
.getSignalSource();
94 AVC::SignalSubunitAddress
* pSyncPlugSubunitAddress
95 = dynamic_cast<AVC::SignalSubunitAddress
*>( pSyncPlugSignalAddress
);
96 if (pSyncPlugSubunitAddress
) {
97 debugOutput(DEBUG_LEVEL_VERBOSE
, "Sync mode 0x%02x\n",
98 ( pSyncPlugSubunitAddress
->m_subunitType
<< 3
99 | pSyncPlugSubunitAddress
->m_subunitId
) << 8
100 | pSyncPlugSubunitAddress
->m_plugId
);
104 AVC::SignalUnitAddress
* pSyncPlugUnitAddress
105 = dynamic_cast<AVC::SignalUnitAddress
*>( pSyncPlugSignalAddress
);
106 if (pSyncPlugUnitAddress
) {
107 debugOutput(DEBUG_LEVEL_VERBOSE
, "Sync mode 0x%02x\n",
108 0xff << 8 | pSyncPlugUnitAddress
->m_plugId
);
112 debugError( "Could not retrieve sync mode\n" );
116 FFADODevice::ClockSource
117 Device::getActiveClockSource()
119 switch (getClkSrc()) {
121 m_intl_clksrc
.active
= true;
122 m_spdif_clksrc
.active
= false;
123 return m_intl_clksrc
;
125 m_intl_clksrc
.active
= false;
126 m_spdif_clksrc
.active
= true;
127 return m_spdif_clksrc
;
130 s
.type
= eCT_Invalid
;
136 Device::setActiveClockSource(ClockSource s
)
138 AVC::SignalSourceCmd
cmd(get1394Service());
139 cmd
.setCommandType(AVC::AVCCommand::eCT_Control
);
140 cmd
.setNodeId(getNodeId());
141 cmd
.setSubunitType(AVC::eST_Unit
);
142 cmd
.setSubunitId(0xff);
143 cmd
.setVerbose(getDebugLevel());
145 AVC::SignalSubunitAddress dst
;
146 dst
.m_subunitType
= AVC::eST_Music
;
147 dst
.m_subunitId
= 0x00;
149 cmd
.setSignalDestination(dst
);
152 AVC::SignalSubunitAddress src
;
153 src
.m_subunitType
= AVC::eST_Music
;
154 src
.m_subunitId
= 0x00;
156 cmd
.setSignalSource( src
);
158 AVC::SignalUnitAddress src
;
160 cmd
.setSignalSource(src
);
164 debugError( "Signal source command failed\n" );
171 } // namespace Firebox
172 } // namespace Presonus