root/branches/streaming-rework/src/rme/rme_avdevice.cpp

Revision 415, 5.1 kB (checked in by pieterpalmers, 16 years ago)

ieee1394service:
- implemented 64bit compare-swap-lock operation (needed for DICE)
- small name change of (un)registerARMhandler to (un)registerARMHandler

iavdevice.h:
- made the stream start/stop functions return bool instead of int
- updated function documentation for consistency and to reflect changes

BeBoB avdevice:
- replaced the 2 fixed streamprocessor pointers with a 2 vectors of streamprocessors
- implemented the 'snoop mode' (cannot be activated yet)

libstreaming:
- removed unused 'type' attribute from AmdtpPortInfo? & children

mh_avdevice, motu_avdevice, rme_avdevice:
- replaced m_1394service with m_p1394service for consistence

maudio_avdevice.cpp:
- removed unused code

Line 
1 /* rme_avdevice.cpp
2  * Copyright (C) 2006 by Jonathan Woithe
3  * Copyright (C) 2006,2007 by Pieter Palmers
4  *
5  * This file is part of FreeBob.
6  *
7  * FreeBob is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  * FreeBob is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with FreeBob; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA.
20  */
21 #warning RME support is currently useless (detection only)
22
23 #include "rme/rme_avdevice.h"
24
25 #include "libieee1394/configrom.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include "debugmodule/debugmodule.h"
29
30 #include <string>
31 #include <stdint.h>
32 #include <assert.h>
33 #include <netinet/in.h>
34
35 #include <libraw1394/csr.h>
36
37 namespace Rme {
38
39 IMPL_DEBUG_MODULE( RmeDevice, RmeDevice, DEBUG_LEVEL_NORMAL );
40
41 // to define the supported devices
42 static VendorModelEntry supportedDeviceList[] =
43 {
44     {0x00000a35, 0x0001, "RME", "Fireface-800"},  // RME Fireface-800
45 };
46
47 RmeDevice::RmeDevice( std::auto_ptr< ConfigRom >( configRom ),
48                     Ieee1394Service& ieee1394service,
49                     int nodeId,
50                     int verboseLevel )
51     : m_configRom( configRom )
52     , m_p1394Service( &ieee1394service )
53     , m_model( NULL )
54     , m_nodeId( nodeId )
55     , m_verboseLevel( verboseLevel )
56     , m_id(0)
57     , m_iso_recv_channel ( -1 )
58     , m_iso_send_channel ( -1 )
59     , m_bandwidth ( -1 )
60 //    , m_receiveProcessor ( 0 )
61 //    , m_transmitProcessor ( 0 )
62    
63 {
64     setDebugLevel( verboseLevel );
65    
66     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Rme::RmeDevice (NodeID %d)\n",
67                  nodeId );
68
69 }
70
71 RmeDevice::~RmeDevice()
72 {
73     // Free ieee1394 bus resources if they have been allocated
74     if (m_p1394Service != NULL) {
75         if(m_p1394Service->freeIsoChannel(m_iso_recv_channel)) {
76             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free recv iso channel %d\n", m_iso_recv_channel);
77            
78         }
79         if(m_p1394Service->freeIsoChannel(m_iso_send_channel)) {
80             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel);
81            
82         }
83     }
84 }
85
86 ConfigRom&
87 RmeDevice::getConfigRom() const
88 {
89     return *m_configRom;
90 }
91
92 bool
93 RmeDevice::probe( ConfigRom& configRom )
94 {
95     unsigned int vendorId = configRom.getNodeVendorId();
96     unsigned int modelId = configRom.getModelId();
97
98     for ( unsigned int i = 0;
99           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
100           ++i )
101     {
102         if ( ( supportedDeviceList[i].vendor_id == vendorId )
103              && ( supportedDeviceList[i].model_id == modelId )
104            )
105         {
106             return true;
107         }
108     }
109
110     return false;
111 }
112
113 bool
114 RmeDevice::discover()
115 {
116     unsigned int vendorId = m_configRom->getNodeVendorId();
117     unsigned int modelId = m_configRom->getModelId();
118
119     for ( unsigned int i = 0;
120           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
121           ++i )
122     {
123         if ( ( supportedDeviceList[i].vendor_id == vendorId )
124              && ( supportedDeviceList[i].model_id == modelId )
125            )
126         {
127             m_model = &(supportedDeviceList[i]);
128         }
129     }
130
131     if (m_model != NULL) {
132         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
133                 m_model->vendor_name, m_model->model_name);
134         return true;
135     }
136
137     return false;
138 }
139
140 int
141 RmeDevice::getSamplingFrequency( ) {
142 /*
143  * Retrieve the current sample rate from the RME device.
144  */
145         return 48000;
146 }
147
148 bool
149 RmeDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency )
150 {
151 /*
152  * Set the RME device's samplerate.
153  */
154         if (samplingFrequency == eSF_48000Hz)
155                 return true;
156         return false;
157 }
158
159 bool RmeDevice::setId( unsigned int id) {
160         debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id);
161         m_id=id;
162         return true;
163 }
164
165 bool
166 RmeDevice::lock() {
167
168     return true;
169 }
170
171
172 bool
173 RmeDevice::unlock() {
174
175     return true;
176 }
177
178 void
179 RmeDevice::showDevice() const
180 {
181         debugOutput(DEBUG_LEVEL_VERBOSE,
182                 "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,
183                 m_nodeId);
184 }
185
186 bool
187 RmeDevice::prepare() {
188
189         debugOutput(DEBUG_LEVEL_NORMAL, "Preparing RmeDevice...\n" );
190
191         return true;
192 }
193
194 int
195 RmeDevice::getStreamCount() {
196         return 0; // one receive, one transmit
197 }
198
199 FreebobStreaming::StreamProcessor *
200 RmeDevice::getStreamProcessorByIndex(int i) {
201     return NULL;
202 }
203
204 bool
205 RmeDevice::startStreamByIndex(int i) {
206     return false;
207 }
208
209 bool
210 RmeDevice::stopStreamByIndex(int i) {
211     return false;
212
213 }
214
215 signed int RmeDevice::getIsoRecvChannel(void) {
216         return m_iso_recv_channel;
217 }
218
219 signed int RmeDevice::getIsoSendChannel(void) {
220         return m_iso_send_channel;
221 }
222
223 signed int RmeDevice::getEventSize(unsigned int dir) {
224     return 0;
225 }
226
227 }
Note: See TracBrowser for help on using the browser.