root/trunk/libffado/src/ffadodevice.cpp

Revision 739, 4.6 kB (checked in by ppalmers, 15 years ago)

- Adapt the ffado external API (upgrade to v3)

NEEDS NEW JACK BACKEND

- simplify FFADODevice constructor even more
- implement first framework support for supporting multiple adapters.

currently all firewire adapters are scanned for supported devices unless specified otherwise
however attaching devices to separate adapters is not supported. using multiple adapters at
that are connected together might work.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  * Copyright (C) 2005-2007 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 library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
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( std::auto_ptr<ConfigRom>( configRom ))
38     : Control::Container()
39     , m_pConfigRom( configRom )
40 {
41     addOption(Util::OptionContainer::Option("id",std::string("dev?")));
42
43     std::ostringstream nodestr;
44     nodestr << "node" << getConfigRom().getNodeId();
45
46     if (!addElement(&getConfigRom())) {
47         debugWarning("failed to add ConfigRom to Control::Container\n");
48     }
49 }
50
51 FFADODevice::~FFADODevice()
52 {
53     if (!deleteElement(&getConfigRom())) {
54         debugWarning("failed to remove ConfigRom from Control::Container\n");
55     }
56 }
57
58 FFADODevice *
59 FFADODevice::createDevice(std::auto_ptr<ConfigRom>( x ))
60 {
61     // re-implement this!!
62     assert(0);
63     return NULL;
64 }
65
66 std::string
67 FFADODevice::getName()
68 {
69     return getConfigRom().getGuidString();
70 }
71
72 int
73 FFADODevice::getNodeId()
74 {
75     return getConfigRom().getNodeId();
76 }
77
78 bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) {
79     assert(a);
80     assert(b);
81     return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom());
82 }
83
84 ConfigRom&
85 FFADODevice::getConfigRom() const
86 {
87     return *m_pConfigRom;
88 }
89
90 Ieee1394Service&
91 FFADODevice::get1394Service()
92 {
93     return getConfigRom().get1394Service();
94 }
95
96 bool
97 FFADODevice::loadFromCache()
98 {
99     return false;
100 }
101
102 bool
103 FFADODevice::saveCache()
104 {
105     return false;
106 }
107
108 enum FFADODevice::eSyncState
109 FFADODevice::getSyncState( ) {
110     return eSS_Unknown;
111 }
112
113 bool
114 FFADODevice::setId( unsigned int id)
115 {
116     bool retval;
117     // FIXME: decent ID system nescessary
118     std::ostringstream idstr;
119     idstr << "dev" << id;
120     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str());
121
122     retval=setOption("id",idstr.str());
123     return retval;
124 }
125
126 void
127 FFADODevice::handleBusReset()
128 {
129     debugOutput( DEBUG_LEVEL_VERBOSE, "Handle bus reset...\n");
130    
131     // update the config rom node id
132     sleep(1);
133     getConfigRom().setVerboseLevel(getDebugLevel());
134     getConfigRom().updatedNodeId();
135
136 }
137
138 void
139 FFADODevice::setVerboseLevel(int l)
140 {
141     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
142     setDebugLevel(l);
143     getConfigRom().setVerboseLevel(l);
144 }
145
146 void
147 FFADODevice::showDevice()
148 {
149     Ieee1394Service& s = getConfigRom().get1394Service();
150     debugOutput(DEBUG_LEVEL_NORMAL, "Attached to port.......: %d (%s)\n",
151                                     s.getPort(), s.getPortName().c_str());
152     debugOutput(DEBUG_LEVEL_NORMAL, "Node...................: %d\n", getNodeId());
153     debugOutput(DEBUG_LEVEL_NORMAL, "GUID...................: %s\n",
154                                     getConfigRom().getGuidString().c_str());
155
156     std::string id=std::string("dev? [none]");
157     getOption("id", id);
158
159     debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str());
160
161     flushDebugOutput();
162 }
163
164
165 bool
166 FFADODevice::enableStreaming() {
167     return true;
168 }
169
170 bool
171 FFADODevice::disableStreaming() {
172     return true;
173 }
174
175 const char *
176 FFADODevice::ClockSourceTypeToString(enum eClockSourceType t)
177 {
178     switch(t) {
179         default:            return "Erratic type      ";
180         case eCT_Invalid:   return "Invalid           ";
181         case eCT_Internal:  return "Internal          ";
182         case eCT_1394Bus:   return "1394 Bus          ";
183         case eCT_SytMatch:  return "Compound Syt Match";
184         case eCT_SytStream: return "Sync Syt Match    ";
185         case eCT_WordClock: return "WordClock         ";
186         case eCT_SPDIF:     return "SPDIF             ";
187         case eCT_ADAT:      return "ADAT              ";
188         case eCT_TDIF:      return "TDIF              ";
189         case eCT_AES:       return "AES               ";
190     }
191 }
Note: See TracBrowser for help on using the browser.