Changeset 341
- Timestamp:
- 12/26/06 08:21:31 (16 years ago)
- Files:
-
- branches/libfreebob-2.0/AUTHORS (modified) (1 diff)
- branches/libfreebob-2.0/README (modified) (1 diff)
- branches/libfreebob-2.0/src/bebob/bebob_avdevice_subunit.cpp (modified) (1 diff)
- branches/libfreebob-2.0/src/bebob/bebob_avplug.cpp (modified) (5 diffs)
- branches/libfreebob-2.0/src/bebob/bebob_functionblock.cpp (modified) (7 diffs)
- branches/libfreebob-2.0/src/bebob/bebob_functionblock.h (modified) (7 diffs)
- branches/libfreebob-2.0/src/debugmodule/debugmodule.h (modified) (2 diffs)
- branches/libfreebob-2.0/src/devicemanager.cpp (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp (modified) (4 diffs)
- branches/libfreebob-2.0/src/libstreaming/IsoHandler.h (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp (modified) (3 diffs)
- branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.h (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp (modified) (10 diffs)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/AUTHORS
r336 r341 1 Pieter Palmers <pieterpalmers@users.sourceforge.net>2 1 Daniel Wagner <wagi@monom.org> 3 2 Pieter Palmers <pieterpalmers@users.sourceforge.net> branches/libfreebob-2.0/README
r336 r341 1 FreeBoB version 1. 0.02 ===================== 1 FreeBoB version 1.999.0 2 ======================= 3 3 4 4 This project aims to provide a free driver implemenation for the BeBoB branches/libfreebob-2.0/src/bebob/bebob_avdevice_subunit.cpp
r336 r341 44 44 , m_verboseLevel( verboseLevel ) 45 45 { 46 if ( m_verboseLevel ) { 47 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 48 } 46 setDebugLevel( m_verboseLevel ); 49 47 } 50 48 branches/libfreebob-2.0/src/bebob/bebob_avplug.cpp
r336 r341 57 57 , m_globalId( m_globalIdCounter++ ) 58 58 { 59 if ( m_verboseLevel ) { 60 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 61 } 59 setDebugLevel( m_verboseLevel ); 62 60 debugOutput( DEBUG_LEVEL_VERBOSE, 63 61 "nodeId = %d, subunitType = %d, " … … 883 881 884 882 if ( plug ) { 885 debugOutput( DEBUG_LEVEL_ NORMAL,883 debugOutput( DEBUG_LEVEL_VERBOSE, 886 884 "'(%d) %s' has a connection to '(%d) %s'\n", 887 885 getGlobalId(), … … 1315 1313 plugId = pUnitPlugAddress->m_plugId; 1316 1314 1317 debugOutput( DEBUG_LEVEL_ NORMAL,1315 debugOutput( DEBUG_LEVEL_VERBOSE, 1318 1316 "'(%d) %s': Remote plug is a unit plug " 1319 1317 "(%s, %s, %d)\n", … … 1481 1479 : m_verboseLevel( verboseLevel ) 1482 1480 { 1483 if ( m_verboseLevel ) { 1484 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 1485 } 1481 setDebugLevel( m_verboseLevel ); 1486 1482 } 1487 1483 … … 1489 1485 : m_verboseLevel( rhs.m_verboseLevel ) 1490 1486 { 1491 if ( m_verboseLevel ) { 1492 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 1493 } 1487 setDebugLevel( m_verboseLevel ); 1494 1488 } 1495 1489 branches/libfreebob-2.0/src/bebob/bebob_functionblock.cpp
r336 r341 35 35 no_of_input_plugs_t nrOfInputPlugs, 36 36 no_of_output_plugs_t nrOfOutputPlugs, 37 boolverbose )37 int verbose ) 38 38 : m_subunit( &subunit ) 39 39 , m_type( type ) … … 44 44 , m_verbose( verbose ) 45 45 { 46 if ( m_verbose ) { 47 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 48 } 46 setDebugLevel( verbose ); 49 47 } 50 48 … … 157 155 no_of_input_plugs_t nrOfInputPlugs, 158 156 no_of_output_plugs_t nrOfOutputPlugs, 159 boolverbose )157 int verbose ) 160 158 : FunctionBlock( subunit, 161 159 eFBT_AudioSubunitSelector, … … 192 190 no_of_input_plugs_t nrOfInputPlugs, 193 191 no_of_output_plugs_t nrOfOutputPlugs, 194 boolverbose )192 int verbose ) 195 193 : FunctionBlock( subunit, 196 194 eFBT_AudioSubunitFeature, … … 227 225 no_of_input_plugs_t nrOfInputPlugs, 228 226 no_of_output_plugs_t nrOfOutputPlugs, 229 boolverbose )227 int verbose ) 230 228 : FunctionBlock( subunit, 231 229 eFBT_AudioSubunitProcessing, … … 262 260 no_of_input_plugs_t nrOfInputPlugs, 263 261 no_of_output_plugs_t nrOfOutputPlugs, 264 boolverbose )262 int verbose ) 265 263 : FunctionBlock( subunit, 266 264 eFBT_AudioSubunitProcessing, … … 297 295 no_of_input_plugs_t nrOfInputPlugs, 298 296 no_of_output_plugs_t nrOfOutputPlugs, 299 boolverbose )297 int verbose ) 300 298 : FunctionBlock( subunit, 301 299 eFBT_AudioSubunitCodec, branches/libfreebob-2.0/src/bebob/bebob_functionblock.h
r336 r341 53 53 no_of_input_plugs_t nrOfInputPlugs, 54 54 no_of_output_plugs_t nrOfOutputPlugs, 55 boolverbose );55 int verbose ); 56 56 FunctionBlock( const FunctionBlock& rhs ); 57 57 virtual ~FunctionBlock(); … … 73 73 no_of_input_plugs_t m_nrOfInputPlugs; 74 74 no_of_output_plugs_t m_nrOfOutputPlugs; 75 boolm_verbose;75 int m_verbose; 76 76 77 77 AvPlugVector m_plugs; … … 93 93 no_of_input_plugs_t nrOfInputPlugs, 94 94 no_of_output_plugs_t nrOfOutputPlugs, 95 boolverbose);95 int verbose); 96 96 FunctionBlockSelector( const FunctionBlockSelector& rhs ); 97 97 virtual ~FunctionBlockSelector(); … … 110 110 no_of_input_plugs_t nrOfInputPlugs, 111 111 no_of_output_plugs_t nrOfOutputPlugs, 112 boolverbose);112 int verbose); 113 113 FunctionBlockFeature( const FunctionBlockFeature& rhs ); 114 114 virtual ~FunctionBlockFeature(); … … 127 127 no_of_input_plugs_t nrOfInputPlugs, 128 128 no_of_output_plugs_t nrOfOutputPlugs, 129 boolverbose );129 int verbose ); 130 130 FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs ); 131 131 virtual ~FunctionBlockEnhancedMixer(); … … 144 144 no_of_input_plugs_t nrOfInputPlugs, 145 145 no_of_output_plugs_t nrOfOutputPlugs, 146 boolverbose );146 int verbose ); 147 147 FunctionBlockProcessing( const FunctionBlockProcessing& rhs ); 148 148 virtual ~FunctionBlockProcessing(); … … 161 161 no_of_input_plugs_t nrOfInputPlugs, 162 162 no_of_output_plugs_t nrOfOutputPlugs, 163 boolverbose);163 int verbose); 164 164 FunctionBlockCodec( const FunctionBlockCodec& rhs ); 165 165 virtual ~FunctionBlockCodec(); branches/libfreebob-2.0/src/debugmodule/debugmodule.h
r336 r341 126 126 */ 127 127 128 #define DO_PREEMPTION_CHECKING128 // #define DO_PREEMPTION_CHECKING 129 129 130 130 #include <sys/time.h> … … 132 132 #ifdef DO_PREEMPTION_CHECKING 133 133 #define CHECK_PREEMPTION(onoff) \ 134 gettimeofday (1, (onoff))134 gettimeofday((struct timeval *)1, (struct timezone *)onoff) 135 135 #else 136 #define CHECK_PREEMPTION( engine,onoff)136 #define CHECK_PREEMPTION(onoff) 137 137 #endif 138 138 branches/libfreebob-2.0/src/devicemanager.cpp
r336 r341 90 90 DeviceManager::discover( int verboseLevel ) 91 91 { 92 switch ( verboseLevel ) { 93 case 3: 94 m_1394Service->setVerbose( true ); 95 case 1: 96 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 97 } 92 93 setDebugLevel( verboseLevel ); 94 m_1394Service->setVerbose( verboseLevel ); 98 95 99 96 for ( IAvDeviceVectorIterator it = m_avDevices.begin(); branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp
r309 r341 32 32 #include <netinet/in.h> 33 33 #include <assert.h> 34 34 #include <unistd.h> 35 35 36 36 #include <iostream> … … 127 127 raw1394_set_bus_reset_handler(m_handle, busreset_handler); 128 128 129 // update the cycle counter value for initial value 130 updateCycleCounter(); 131 129 132 return true; 130 133 } … … 145 148 #define CSR_REGISTER_BASE 0xfffff0000000ULL 146 149 150 #define CYCLE_COUNTER_GET_SECS(x) (((x & 0xFE000000) >> 25)) 151 #define CYCLE_COUNTER_GET_CYCLES(x) (((x & 0x01FFF000) >> 12)) 152 #define CYCLE_COUNTER_GET_TICKS(x) (((x & 0x00000FFF))) 153 #define CYCLE_COUNTER_TO_TICKS(x) ((CYCLE_COUNTER_GET_SECS(x) * 24576000) +\ 154 (CYCLE_COUNTER_GET_CYCLES(x) * 3072) +\ 155 (CYCLE_COUNTER_GET_TICKS(x) )) 156 147 157 unsigned int IsoHandler::getCycleCounter() { 158 return m_cyclecounter; 159 } 160 161 void IsoHandler::updateCycleCounter() { 148 162 quadlet_t buf=0; 149 163 … … 153 167 raw1394_read(m_handle_util, raw1394_get_local_id(m_handle_util), 154 168 CSR_REGISTER_BASE | CSR_CYCLE_TIME, 4, &buf); 155 156 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Current timestamp: %08X = %u\n",buf, ntohl(buf));157 169 158 return ntohl(buf) & 0xFFFFFFFF; 170 m_cyclecounter= ntohl(buf) & 0xFFFFFFFF; 171 172 // debugOutput(DEBUG_LEVEL_VERBOSE,"Updating timestamp: %08X (%2u sec + %2u cycles + %04u ticks)\n", 173 // m_cyclecounter, 174 // CYCLE_COUNTER_GET_SECS(m_cyclecounter), 175 // CYCLE_COUNTER_GET_CYCLES(m_cyclecounter), 176 // CYCLE_COUNTER_GET_TICKS(m_cyclecounter) 177 // ); 178 179 180 usleep(100); 159 181 } 160 182 branches/libfreebob-2.0/src/libstreaming/IsoHandler.h
r309 r341 111 111 virtual bool prepare() = 0; 112 112 113 // get the most recent cycle counter value 114 // RT safe 113 115 unsigned int getCycleCounter(); 116 117 // update the cycle counter cache 118 // not RT safe 119 // the isohandlermanager is responsible for calling this! 120 void updateCycleCounter(); 114 121 115 122 protected: … … 120 127 unsigned int m_max_packet_size; 121 128 int m_irq_interval; 129 unsigned int m_cyclecounter; 122 130 123 131 int m_packetcount; branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp
r309 r341 57 57 } 58 58 59 // Intel recommends that a serializing instruction 60 // should be called before and after rdtsc. 61 // CPUID is a serializing instruction. 62 #define read_rdtsc(time) \ 63 __asm__ __volatile__( \ 64 "pushl %%ebx\n\t" \ 65 "cpuid\n\t" \ 66 "rdtsc\n\t" \ 67 "mov %%eax,(%0)\n\t" \ 68 "cpuid\n\t" \ 69 "popl %%ebx\n\t" \ 70 : /* no output */ \ 71 : "S"(&time) \ 72 : "eax", "ecx", "edx", "memory") 73 74 static inline unsigned long debugGetCurrentUTime() { 75 unsigned retval; 76 read_rdtsc(retval); 77 return retval; 78 } 79 59 // the IsoHandlerManager thread updates the handler caches 60 // it doesn't iterate them !!! 80 61 bool IsoHandlerManager::Execute() 62 { 63 updateCycleCounters(); 64 return true; 65 } 66 67 bool IsoHandlerManager::iterate() 81 68 { 82 69 int err; … … 84 71 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 85 72 86 unsigned long tstamp=debugGetCurrentUTime();87 88 73 err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout); 89 90 // debugOutput(DEBUG_LEVEL_VERBOSE, "Poll took: %6d\n", debugGetCurrentUTime()-tstamp);91 74 92 75 if (err == -1) { … … 111 94 assert(s); 112 95 113 unsigned int packetcount_prev=s->getPacketCount();114 115 tstamp=debugGetCurrentUTime();116 117 96 s->iterate(); 118 /* debugOutput(DEBUG_LEVEL_VERBOSE, "Iterate %p: time: %6d | packets: %3d\n", 119 s, debugGetCurrentUTime()-tstamp, s->getPacketCount()-packetcount_prev 120 );*/ 121 } 122 } 123 return true; 124 97 } 98 } 99 100 return true; 101 102 } 103 104 // updates the internal cycle counter caches of the handlers 105 void IsoHandlerManager::updateCycleCounters() { 106 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 107 108 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 109 it != m_IsoHandlers.end(); 110 ++it ) 111 { 112 (*it)->updateCycleCounter(); 113 } 125 114 } 126 115 branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.h
r250 r341 93 93 94 94 protected: 95 96 95 97 // RunnableInterface interface 96 98 bool Execute(); // note that this is called in we while(running) loop 97 99 bool Init(); 98 100 99 101 // iterate all handlers 102 bool iterate(); 103 104 // updates the cycle counter caches of all handlers 105 void updateCycleCounters(); 106 100 107 // note: there is a disctinction between streams and handlers 101 108 // because one handler can serve multiple streams (in case of branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp
r312 r341 150 150 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 151 151 152 // and the tread that runs the runner153 m_streamingThread=new FreebobUtil::PosixThread(this, m_thread_realtime, m_thread_priority , PTHREAD_CANCEL_DEFERRED);152 // the tread that runs the packet iterators 153 m_streamingThread=new FreebobUtil::PosixThread(this, m_thread_realtime, m_thread_priority+5, PTHREAD_CANCEL_DEFERRED); 154 154 if(!m_streamingThread) { 155 155 debugFatal("Could not create streaming thread\n"); … … 166 166 m_isoManager->setVerboseLevel(getDebugLevel()); 167 167 168 if(!m_isoManager->Init()) { 169 debugFatal("Could not init IsoHandlerManager\n"); 168 // the tread that keeps the handler's cycle counters up to date 169 // NOTE: is lower priority nescessary? it can block 170 m_isoManagerThread=new FreebobUtil::PosixThread(m_isoManager, m_thread_realtime, m_thread_priority+6, PTHREAD_CANCEL_DEFERRED); 171 if(!m_isoManagerThread) { 172 debugFatal("Could not create iso manager thread\n"); 170 173 return false; 171 174 } … … 225 228 bool xrun_has_occured=false; 226 229 bool this_period_ready; 227 228 unsigned long tstamp_enter=debugGetCurrentTSC(); 229 230 230 231 // debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "------------- EXECUTE -----------\n"); 231 232 if(!m_isoManager-> Execute()) {233 debugFatal("Could not execute isoManager\n");232 233 if(!m_isoManager->iterate()) { 234 debugFatal("Could not iterate the isoManager\n"); 234 235 return false; 235 236 } 236 237 237 unsigned long tstamp_iso=debugGetCurrentTSC();238 239 238 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " RCV PROC: "); 240 239 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); … … 266 265 } 267 266 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE, "\n"); 268 269 unsigned long tstamp_periodcheck=debugGetCurrentTSC();270 267 271 268 if(xrun_has_occured) { … … 275 272 m_xrun_happened=true; 276 273 sem_post(&m_period_semaphore); 274 277 275 return false; // stop thread 278 276 } … … 300 298 m_nbperiods++; 301 299 } 302 303 unsigned long tstamp_exit=debugGetCurrentTSC();304 305 // debugOutput( DEBUG_LEVEL_VERBOSE, "EXECUTE TIME: ISO: %6d | PeriodCheck: %6d | FrameCounter: %6d \n",306 // tstamp_iso-tstamp_enter, tstamp_periodcheck-tstamp_iso, tstamp_exit-tstamp_periodcheck307 // );308 300 309 301 return true; … … 364 356 m_streamingThread->Start(); 365 357 358 // start the runner thread 359 m_isoManagerThread->Start(); 360 366 361 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to start running...\n"); 367 362 // we have to wait until all streamprocessors indicate that they are running … … 425 420 } 426 421 427 (*it)->reset();422 (*it)->reset(); 428 423 429 424 if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) { … … 441 436 } 442 437 443 (*it)->reset();438 (*it)->reset(); 444 439 445 440 if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) { … … 503 498 504 499 505 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping thread ...\n");500 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping threads...\n"); 506 501 507 502 m_streamingThread->Stop(); 503 m_isoManagerThread->Stop(); 508 504 509 505 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handlers...\n"); branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.h
r250 r341 124 124 125 125 FreebobUtil::PosixThread *m_streamingThread; 126 FreebobUtil::PosixThread *m_isoManagerThread; 126 127 127 128 unsigned int m_nbperiods;