root/trunk/libffado/src/ffadodevice.cpp

Revision 864, 5.0 kB (checked in by ppalmers, 16 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
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.
14  *
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.
19  *
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/>.
22  *
23  */
24
25 #include "ffadodevice.h"
26
27 #include "libieee1394/configrom.h"
28 #include "libieee1394/ieee1394service.h"
29
30 #include <iostream>
31 #include <sstream>
32
33 #include <assert.h>
34
35 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL );
36
37 FFADODevice::FFADODevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) )
38     : Control::Container()
39     , m_pDeviceManager( d )
40     , m_pConfigRom( configRom )
41 {
42     addOption(Util::OptionContainer::Option("id",std::string("dev?")));
43
44     std::ostringstream nodestr;
45     nodestr << "node" << getConfigRom().getNodeId();
46
47     if (!addElement(&getConfigRom())) {
48         debugWarning("failed to add ConfigRom to Control::Container\n");
49     }
50 }
51
52 FFADODevice::~FFADODevice()
53 {
54     if (!deleteElement(&getConfigRom())) {
55         debugWarning("failed to remove ConfigRom from Control::Container\n");
56     }
57 }
58
59 FFADODevice *
60 FFADODevice::createDevice(std::auto_ptr<ConfigRom>( x ))
61 {
62     // re-implement this!!
63     assert(0);
64     return NULL;
65 }
66
67 std::string
68 FFADODevice::getName()
69 {
70     return getConfigRom().getGuidString();
71 }
72
73 int
74 FFADODevice::getNodeId()
75 {
76     return getConfigRom().getNodeId();
77 }
78
79 bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) {
80     assert(a);
81     assert(b);
82     return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom());
83 }
84
85 ConfigRom&
86 FFADODevice::getConfigRom() const
87 {
88     return *m_pConfigRom;
89 }
90
91 Ieee1394Service&
92 FFADODevice::get1394Service()
93 {
94     return getConfigRom().get1394Service();
95 }
96
97 bool
98 FFADODevice::loadFromCache()
99 {
100     return false;
101 }
102
103 bool
104 FFADODevice::saveCache()
105 {
106     return false;
107 }
108
109 enum FFADODevice::eSyncState
110 FFADODevice::getSyncState( ) {
111     return eSS_Unknown;
112 }
113
114 bool
115 FFADODevice::setId( unsigned int id)
116 {
117     bool retval;
118     // FIXME: decent ID system nescessary
119     std::ostringstream idstr;
120     idstr << "dev" << id;
121     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str());
122
123     retval=setOption("id",idstr.str());
124     return retval;
125 }
126
127 void
128 FFADODevice::handleBusReset()
129 {
130     debugOutput( DEBUG_LEVEL_VERBOSE, "Handle bus reset...\n");
131    
132     // update the config rom node id
133     sleep(1);
134     getConfigRom().setVerboseLevel(getDebugLevel());
135     getConfigRom().updatedNodeId();
136
137 }
138
139 void
140 FFADODevice::setVerboseLevel(int l)
141 {
142     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
143     setDebugLevel(l);
144     getConfigRom().setVerboseLevel(l);
145 }
146
147 void
148 FFADODevice::showDevice()
149 {
150     Ieee1394Service& s = getConfigRom().get1394Service();
151     debugOutput(DEBUG_LEVEL_NORMAL, "Attached to port.......: %d (%s)\n",
152                                     s.getPort(), s.getPortName().c_str());
153     debugOutput(DEBUG_LEVEL_NORMAL, "Node...................: %d\n", getNodeId());
154     debugOutput(DEBUG_LEVEL_NORMAL, "Vendor name............: %s\n",
155                                     getConfigRom().getVendorName().c_str());
156     debugOutput(DEBUG_LEVEL_NORMAL, "Model name.............: %s\n",
157                                     getConfigRom().getModelName().c_str());
158     debugOutput(DEBUG_LEVEL_NORMAL, "GUID...................: %s\n",
159                                     getConfigRom().getGuidString().c_str());
160
161     std::string id=std::string("dev? [none]");
162     getOption("id", id);
163
164     debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str());
165
166     flushDebugOutput();
167 }
168
169
170 bool
171 FFADODevice::enableStreaming() {
172     return true;
173 }
174
175 bool
176 FFADODevice::disableStreaming() {
177     return true;
178 }
179
180 const char *
181 FFADODevice::ClockSourceTypeToString(enum eClockSourceType t)
182 {
183     switch(t) {
184         default:            return "Erratic type      ";
185         case eCT_Invalid:   return "Invalid           ";
186         case eCT_Internal:  return "Internal          ";
187         case eCT_1394Bus:   return "1394 Bus          ";
188         case eCT_SytMatch:  return "Compound Syt Match";
189         case eCT_SytStream: return "Sync Syt Match    ";
190         case eCT_WordClock: return "WordClock         ";
191         case eCT_SPDIF:     return "SPDIF             ";
192         case eCT_ADAT:      return "ADAT              ";
193         case eCT_TDIF:      return "TDIF              ";
194         case eCT_AES:       return "AES               ";
195     }
196 }
Note: See TracBrowser for help on using the browser.