dice: remove some prototype code which accidently made its way into r2416.
[ffado.git] / libffado / src / ffadodevice.cpp
blob5e5efd7dc7bc18c3e917166a2c0128b22e921346
1 /*
2 * Copyright (C) 2005-2008 by Daniel Wagner
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 "ffadodevice.h"
26 #include "devicemanager.h"
28 #include "libieee1394/configrom.h"
29 #include "libieee1394/ieee1394service.h"
31 #include "libcontrol/Element.h"
32 #include "libcontrol/ClockSelect.h"
33 #include "libcontrol/Nickname.h"
35 #include <iostream>
36 #include <sstream>
37 #include <unistd.h>
39 #include <assert.h>
41 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL );
43 FFADODevice::FFADODevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) )
44 : Control::Container(&d)
45 , m_pConfigRom( configRom )
46 , m_pDeviceManager( d )
48 addOption(Util::OptionContainer::Option("id",m_pConfigRom->getGuidString()));
50 std::ostringstream nodestr;
51 nodestr << "node" << getConfigRom().getNodeId();
53 if (!addElement(&getConfigRom())) {
54 debugWarning("failed to add ConfigRom to Control::Container\n");
57 m_genericContainer = new Control::Container(this, "Generic");
58 if(m_genericContainer == NULL) {
59 debugError("Could not create Control::Container for generic controls\n");
60 } else {
62 if (!addElement(m_genericContainer)) {
63 debugWarning("failed to add generic container to Control::Container\n");
65 // add a generic control for the clock source selection
66 if(!m_genericContainer->addElement(new Control::ClockSelect(*this))) {
67 debugWarning("failed to add clock source control to container\n");
69 // add a generic control for the sample rate selection
70 if(!m_genericContainer->addElement(new Control::SamplerateSelect(*this))) {
71 debugWarning("failed to add sample rate control to container\n");
73 // add a generic control for the nickname
74 if(!m_genericContainer->addElement(new Control::Nickname(*this))) {
75 debugWarning("failed to add Nickname control to container\n");
77 // add a generic control for the streaming status
78 if(!m_genericContainer->addElement(new Control::StreamingStatus(*this))) {
79 debugWarning("failed to add StreamingStatus control to container\n");
84 FFADODevice::~FFADODevice()
86 if (!deleteElement(&getConfigRom())) {
87 debugWarning("failed to remove ConfigRom from Control::Container\n");
90 // remove generic controls if present
91 if(m_genericContainer) {
92 if (!deleteElement(m_genericContainer)) {
93 debugError("Generic controls present but not registered to the avdevice\n");
95 // remove and delete (as in free) child control elements
96 m_genericContainer->clearElements(true);
97 delete m_genericContainer;
101 FFADODevice *
102 FFADODevice::createDevice(std::auto_ptr<ConfigRom>( x ))
104 // re-implement this!!
105 assert(0);
106 return NULL;
109 std::string
110 FFADODevice::getName()
112 return getConfigRom().getGuidString();
116 FFADODevice::getNodeId()
118 return getConfigRom().getNodeId();
121 bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) {
122 assert(a);
123 assert(b);
124 return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom());
127 ConfigRom&
128 FFADODevice::getConfigRom() const
130 return *m_pConfigRom;
133 Ieee1394Service&
134 FFADODevice::get1394Service()
136 return getConfigRom().get1394Service();
139 bool
140 FFADODevice::loadFromCache()
142 return false;
145 bool
146 FFADODevice::saveCache()
148 return false;
151 bool
152 FFADODevice::needsRediscovery()
154 // require rediscovery by default
155 return true;
158 enum FFADODevice::eSyncState
159 FFADODevice::getSyncState( ) {
160 return eSS_Unknown;
163 enum FFADODevice::eStreamingState
164 FFADODevice::getStreamingState()
166 return eSS_Idle;
169 bool
170 FFADODevice::setNickname( std::string name)
172 return false;
175 std::string
176 FFADODevice::getNickname()
178 return "Unsupported";
181 bool
182 FFADODevice::canChangeNickname()
184 return false;
187 void
188 FFADODevice::handleBusReset()
190 debugOutput( DEBUG_LEVEL_VERBOSE, "Handle bus reset...\n");
192 // update the config rom node id
193 sleep(1);
195 Util::MutexLockHelper lock(m_DeviceMutex);
196 getConfigRom().setVerboseLevel(getDebugLevel());
197 getConfigRom().updatedNodeId();
200 void
201 FFADODevice::setVerboseLevel(int l)
203 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
204 setDebugLevel(l);
205 m_DeviceMutex.setVerboseLevel(l);
206 getConfigRom().setVerboseLevel(l);
209 void
210 FFADODevice::showDevice()
212 #ifdef DEBUG
213 Ieee1394Service& s = getConfigRom().get1394Service();
214 debugOutput(DEBUG_LEVEL_NORMAL, "Attached to port.......: %d (%s)\n",
215 s.getPort(), s.getPortName().c_str());
216 debugOutput(DEBUG_LEVEL_NORMAL, "Node...................: %d\n", getNodeId());
217 debugOutput(DEBUG_LEVEL_NORMAL, "Vendor name............: %s\n",
218 getConfigRom().getVendorName().c_str());
219 debugOutput(DEBUG_LEVEL_NORMAL, "Model name.............: %s\n",
220 getConfigRom().getModelName().c_str());
221 debugOutput(DEBUG_LEVEL_NORMAL, "GUID...................: %s\n",
222 getConfigRom().getGuidString().c_str());
224 std::string id=std::string("dev? [none]");
225 getOption("id", id);
227 debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str());
229 flushDebugOutput();
230 #endif
234 bool
235 FFADODevice::enableStreaming() {
236 return true;
239 bool
240 FFADODevice::disableStreaming() {
241 return true;
244 const char *
245 FFADODevice::ClockSourceTypeToString(enum eClockSourceType t)
247 switch(t) {
248 default: return "Erratic type ";
249 case eCT_Invalid: return "Invalid ";
250 case eCT_Internal: return "Internal ";
251 case eCT_1394Bus: return "1394 Bus ";
252 case eCT_SytMatch: return "Compound Syt Match";
253 case eCT_SytStream: return "Sync Syt Match ";
254 case eCT_WordClock: return "WordClock ";
255 case eCT_SPDIF: return "SPDIF ";
256 case eCT_ADAT: return "ADAT ";
257 case eCT_TDIF: return "TDIF ";
258 case eCT_AES: return "AES ";