root/branches/streaming-rework/src/dice/dice_avdevice.cpp

Revision 415, 5.5 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 /* dice_avdevice.cpp
2  * Copyright (C) 2007 by Pieter Palmers
3  *
4  * This file is part of FreeBob.
5  *
6  * FreeBob is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBob is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20 #warning DICE support is currently useless
21
22 #include "dice/dice_avdevice.h"
23 #include "dice/dice_defines.h"
24
25 #include "libieee1394/configrom.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include "libstreaming/AmdtpStreamProcessor.h"
29
30 #include "debugmodule/debugmodule.h"
31
32 #include <string>
33 #include <stdint.h>
34 #include <assert.h>
35 #include <netinet/in.h>
36 #include <libraw1394/csr.h>
37
38
39 namespace Dice {
40
41 IMPL_DEBUG_MODULE( DiceAvDevice, DiceAvDevice, DEBUG_LEVEL_VERBOSE );
42
43 // to define the supported devices
44 static VendorModelEntry supportedDeviceList[] =
45 {
46     {0x00000000, 0x0000, "DICE VENDOR", "XXX"},
47 };
48
49 DiceAvDevice::DiceAvDevice( std::auto_ptr< ConfigRom >( configRom ),
50                     Ieee1394Service& ieee1394service,
51                     int nodeId,
52                     int verboseLevel )
53     : m_configRom( configRom )
54     , m_1394Service( &ieee1394service )
55     , m_model( NULL )
56     , m_nodeId( nodeId )
57     , m_verboseLevel( verboseLevel )
58     , m_id(0)
59     , m_iso_recv_channel ( -1 )
60     , m_iso_send_channel ( -1 )
61 {
62     setDebugLevel( verboseLevel );
63    
64     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Dice::DiceAvDevice (NodeID %d)\n",
65                  nodeId );
66
67 }
68
69 DiceAvDevice::~DiceAvDevice()
70 {
71
72 }
73
74 ConfigRom&
75 DiceAvDevice::getConfigRom() const
76 {
77     return *m_configRom;
78 }
79
80 bool
81 DiceAvDevice::probe( ConfigRom& configRom )
82 {
83     unsigned int vendorId = configRom.getNodeVendorId();
84     unsigned int modelId = configRom.getModelId();
85
86     for ( unsigned int i = 0;
87           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
88           ++i )
89     {
90         if ( ( supportedDeviceList[i].vendor_id == vendorId )
91              && ( supportedDeviceList[i].model_id == modelId )
92            )
93         {
94             return true;
95         }
96     }
97
98     return false;
99 }
100
101 bool
102 DiceAvDevice::discover()
103 {
104     unsigned int vendorId = m_configRom->getNodeVendorId();
105     unsigned int modelId = m_configRom->getModelId();
106
107     for ( unsigned int i = 0;
108           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
109           ++i )
110     {
111         if ( ( supportedDeviceList[i].vendor_id == vendorId )
112              && ( supportedDeviceList[i].model_id == modelId )
113            )
114         {
115             m_model = &(supportedDeviceList[i]);
116         }
117     }
118
119     if (m_model != NULL) {
120         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
121                 m_model->vendor_name, m_model->model_name);
122         return true;
123     }
124
125     return false;
126 }
127
128 int
129 DiceAvDevice::getSamplingFrequency( ) {
130     return 0;
131 }
132
133 bool
134 DiceAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency )
135 {
136
137     return false;
138 }
139
140 bool DiceAvDevice::setId( unsigned int id) {
141     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id);
142     m_id=id;
143     return true;
144 }
145
146 void
147 DiceAvDevice::showDevice() const
148 {
149     debugOutput(DEBUG_LEVEL_VERBOSE,
150         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,
151         m_nodeId);
152 }
153
154 bool
155 DiceAvDevice::prepare() {
156
157     return true;
158 }
159
160 bool
161 DiceAvDevice::lock() {
162
163     return true;
164 }
165
166
167 bool
168 DiceAvDevice::unlock() {
169
170     return true;
171 }
172
173 int
174 DiceAvDevice::getStreamCount() {
175     return 0; // one receive, one transmit
176 }
177
178 FreebobStreaming::StreamProcessor *
179 DiceAvDevice::getStreamProcessorByIndex(int i) {
180
181 //    switch (i) {
182 //    case 0:
183 //        return m_receiveProcessor;
184 //    case 1:
185 //        return m_transmitProcessor;
186 //    default:
187 //        return NULL;
188 //    }
189 //    return 0;
190     return NULL;
191 }
192
193 bool
194 DiceAvDevice::startStreamByIndex(int i) {
195
196     // NOTE: this assumes that you have two streams
197     switch (i) {
198     case 0:
199         // TODO: do the stuff that is nescessary to make the device
200         // transmit a stream
201
202         // Set the streamprocessor channel to the one obtained by
203         // the connection management
204 //        m_receiveProcessor->setChannel(m_iso_recv_channel);
205
206         break;
207     case 1:
208         // TODO: do the stuff that is nescessary to make the device
209         // receive a stream
210
211         // Set the streamprocessor channel to the one obtained by
212         // the connection management
213 //        m_transmitProcessor->setChannel(m_iso_send_channel);
214
215         break;
216        
217     default: // Invalid stream index
218         return false;
219     }
220
221     return true;
222 }
223
224 bool
225 DiceAvDevice::stopStreamByIndex(int i) {
226
227     // TODO: connection management: break connection
228     // cfr the start function
229
230     // NOTE: this assumes that you have two streams
231     switch (i) {
232     case 0:
233         break;
234     case 1:
235         break;
236        
237     default: // Invalid stream index
238         return false;
239     }
240
241     return true;
242 }
243
244 signed int DiceAvDevice::getIsoRecvChannel(void) {
245     return m_iso_recv_channel;
246 }
247
248 signed int DiceAvDevice::getIsoSendChannel(void) {
249     return m_iso_send_channel;
250 }
251
252 }
Note: See TracBrowser for help on using the browser.