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 "presonus_avdevice.h"
30 FireboxDevice::FireboxDevice(DeviceManager
& d
, std::auto_ptr
<ConfigRom
>(configRom
))
31 : BeBoB::Device( d
, configRom
)
33 m_intl_clksrc
.type
= FFADODevice::eCT_Internal
;
34 m_intl_clksrc
.valid
= true;
35 m_intl_clksrc
.locked
= true;
36 m_intl_clksrc
.id
= 0x00;
37 m_intl_clksrc
.slipping
= false;
38 m_intl_clksrc
.description
= "Internal";
40 m_spdif_clksrc
.type
= FFADODevice::eCT_SPDIF
;
41 m_spdif_clksrc
.valid
= true;
42 m_spdif_clksrc
.locked
= true;
43 m_spdif_clksrc
.id
= 0x01;
44 m_spdif_clksrc
.slipping
= false;
45 m_spdif_clksrc
.description
= "S/PDIF (Coaxial)";
47 debugOutput( DEBUG_LEVEL_VERBOSE
, "Created BeBoB::Presonus::FireboxDevice (NodeID %d)\n",
48 getConfigRom().getNodeId() );
51 FireboxDevice::~FireboxDevice()
56 FireboxDevice::showDevice()
58 debugOutput(DEBUG_LEVEL_NORMAL
, "This is a BeBoB::Presonus::FireboxDevice\n");
59 BeBoB::Device::showDevice();
62 FFADODevice::ClockSourceVector
63 FireboxDevice::getSupportedClockSources()
65 FFADODevice::ClockSourceVector r
;
66 r
.push_back(m_intl_clksrc
);
67 r
.push_back(m_spdif_clksrc
);
71 enum FFADODevice::eClockSourceType
72 FireboxDevice::getClkSrc()
74 AVC::SignalSourceCmd
cmd(get1394Service());
75 cmd
.setCommandType(AVC::AVCCommand::eCT_Status
);
76 cmd
.setNodeId(getNodeId());
77 cmd
.setSubunitType(AVC::eST_Unit
);
78 cmd
.setSubunitId(0xff);
79 cmd
.setVerbose(getDebugLevel());
81 AVC::SignalSubunitAddress dst
;
82 dst
.m_subunitType
= AVC::eST_Music
;
83 dst
.m_subunitId
= 0x00;
85 cmd
.setSignalDestination(dst
);
88 debugError( "Signal source command failed\n" );
91 AVC::SignalAddress
* pSyncPlugSignalAddress
= cmd
.getSignalSource();
93 AVC::SignalSubunitAddress
* pSyncPlugSubunitAddress
94 = dynamic_cast<AVC::SignalSubunitAddress
*>( pSyncPlugSignalAddress
);
95 if (pSyncPlugSubunitAddress
) {
96 debugOutput(DEBUG_LEVEL_VERBOSE
, "Sync mode 0x%02x\n",
97 ( pSyncPlugSubunitAddress
->m_subunitType
<< 3
98 | pSyncPlugSubunitAddress
->m_subunitId
) << 8
99 | pSyncPlugSubunitAddress
->m_plugId
);
103 AVC::SignalUnitAddress
* pSyncPlugUnitAddress
104 = dynamic_cast<AVC::SignalUnitAddress
*>( pSyncPlugSignalAddress
);
105 if (pSyncPlugUnitAddress
) {
106 debugOutput(DEBUG_LEVEL_VERBOSE
, "Sync mode 0x%02x\n",
107 0xff << 8 | pSyncPlugUnitAddress
->m_plugId
);
111 debugError( "Could not retrieve sync mode\n" );
115 FFADODevice::ClockSource
116 FireboxDevice::getActiveClockSource()
118 switch (getClkSrc()) {
120 m_intl_clksrc
.active
= true;
121 m_spdif_clksrc
.active
= false;
122 return m_intl_clksrc
;
124 m_intl_clksrc
.active
= false;
125 m_spdif_clksrc
.active
= true;
126 return m_spdif_clksrc
;
129 s
.type
= eCT_Invalid
;
135 FireboxDevice::setActiveClockSource(ClockSource s
)
137 AVC::SignalSourceCmd
cmd(get1394Service());
138 cmd
.setCommandType(AVC::AVCCommand::eCT_Control
);
139 cmd
.setNodeId(getNodeId());
140 cmd
.setSubunitType(AVC::eST_Unit
);
141 cmd
.setSubunitId(0xff);
142 cmd
.setVerbose(getDebugLevel());
144 AVC::SignalSubunitAddress dst
;
145 dst
.m_subunitType
= AVC::eST_Music
;
146 dst
.m_subunitId
= 0x00;
148 cmd
.setSignalDestination(dst
);
151 AVC::SignalSubunitAddress src
;
152 src
.m_subunitType
= AVC::eST_Music
;
153 src
.m_subunitId
= 0x00;
155 cmd
.setSignalSource( src
);
157 AVC::SignalUnitAddress src
;
159 cmd
.setSignalSource(src
);
163 debugError( "Signal source command failed\n" );
170 } // namespace Presonus