Show
Ignore:
Timestamp:
12/26/06 08:21:31 (17 years ago)
Author:
pieterpalmers
Message:

- changed bebob avdevice to use debugmodule instead of printf/cout
- fixed some minor merge side-effects
- implement a RT safe mechanism to obtain the cycle counter.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libfreebob-2.0/AUTHORS

    r336 r341  
    1 Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
    21Daniel Wagner <wagi@monom.org> 
    32Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
  • branches/libfreebob-2.0/README

    r336 r341  
    1 FreeBoB version 1.0.0 
    2 ===================== 
     1FreeBoB version 1.999.0 
     2======================= 
    33 
    44This project aims to provide a free driver implemenation for the BeBoB 
  • branches/libfreebob-2.0/src/bebob/bebob_avdevice_subunit.cpp

    r336 r341  
    4444    , m_verboseLevel( verboseLevel ) 
    4545{ 
    46     if ( m_verboseLevel ) { 
    47         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    48     } 
     46    setDebugLevel( m_verboseLevel ); 
    4947} 
    5048 
  • branches/libfreebob-2.0/src/bebob/bebob_avplug.cpp

    r336 r341  
    5757    , m_globalId( m_globalIdCounter++ ) 
    5858{ 
    59     if ( m_verboseLevel ) { 
    60         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    61     } 
     59    setDebugLevel( m_verboseLevel ); 
    6260    debugOutput( DEBUG_LEVEL_VERBOSE, 
    6361                 "nodeId = %d, subunitType = %d, " 
     
    883881 
    884882    if ( plug ) { 
    885         debugOutput( DEBUG_LEVEL_NORMAL
     883        debugOutput( DEBUG_LEVEL_VERBOSE
    886884                     "'(%d) %s' has a connection to '(%d) %s'\n", 
    887885                     getGlobalId(), 
     
    13151313        plugId = pUnitPlugAddress->m_plugId; 
    13161314 
    1317         debugOutput( DEBUG_LEVEL_NORMAL
     1315        debugOutput( DEBUG_LEVEL_VERBOSE
    13181316                     "'(%d) %s': Remote plug is a unit plug " 
    13191317                     "(%s, %s, %d)\n", 
     
    14811479    : m_verboseLevel( verboseLevel ) 
    14821480{ 
    1483     if ( m_verboseLevel ) { 
    1484         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    1485     } 
     1481    setDebugLevel( m_verboseLevel ); 
    14861482} 
    14871483 
     
    14891485    : m_verboseLevel( rhs.m_verboseLevel ) 
    14901486{ 
    1491     if ( m_verboseLevel ) { 
    1492         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    1493     } 
     1487    setDebugLevel( m_verboseLevel ); 
    14941488} 
    14951489 
  • branches/libfreebob-2.0/src/bebob/bebob_functionblock.cpp

    r336 r341  
    3535    no_of_input_plugs_t nrOfInputPlugs, 
    3636    no_of_output_plugs_t nrOfOutputPlugs, 
    37     bool verbose ) 
     37    int verbose ) 
    3838    : m_subunit( &subunit ) 
    3939    , m_type( type ) 
     
    4444    , m_verbose( verbose ) 
    4545{ 
    46     if ( m_verbose ) { 
    47         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    48     } 
     46    setDebugLevel( verbose ); 
    4947} 
    5048 
     
    157155    no_of_input_plugs_t nrOfInputPlugs, 
    158156    no_of_output_plugs_t nrOfOutputPlugs, 
    159     bool verbose ) 
     157    int verbose ) 
    160158    : FunctionBlock( subunit, 
    161159                     eFBT_AudioSubunitSelector, 
     
    192190    no_of_input_plugs_t nrOfInputPlugs, 
    193191    no_of_output_plugs_t nrOfOutputPlugs, 
    194     bool verbose ) 
     192    int verbose ) 
    195193    : FunctionBlock( subunit, 
    196194                     eFBT_AudioSubunitFeature, 
     
    227225    no_of_input_plugs_t nrOfInputPlugs, 
    228226    no_of_output_plugs_t nrOfOutputPlugs, 
    229     bool verbose ) 
     227    int verbose ) 
    230228    : FunctionBlock( subunit, 
    231229                     eFBT_AudioSubunitProcessing, 
     
    262260    no_of_input_plugs_t nrOfInputPlugs, 
    263261    no_of_output_plugs_t nrOfOutputPlugs, 
    264     bool verbose ) 
     262    int verbose ) 
    265263    : FunctionBlock( subunit, 
    266264                     eFBT_AudioSubunitProcessing, 
     
    297295    no_of_input_plugs_t nrOfInputPlugs, 
    298296    no_of_output_plugs_t nrOfOutputPlugs, 
    299     bool verbose ) 
     297    int verbose ) 
    300298    : FunctionBlock( subunit, 
    301299                     eFBT_AudioSubunitCodec, 
  • branches/libfreebob-2.0/src/bebob/bebob_functionblock.h

    r336 r341  
    5353                   no_of_input_plugs_t nrOfInputPlugs, 
    5454                   no_of_output_plugs_t nrOfOutputPlugs, 
    55                    bool verbose ); 
     55                   int verbose ); 
    5656    FunctionBlock( const FunctionBlock& rhs ); 
    5757    virtual ~FunctionBlock(); 
     
    7373    no_of_input_plugs_t   m_nrOfInputPlugs; 
    7474    no_of_output_plugs_t  m_nrOfOutputPlugs; 
    75     bool m_verbose; 
     75    int m_verbose; 
    7676 
    7777    AvPlugVector m_plugs; 
     
    9393                          no_of_input_plugs_t nrOfInputPlugs, 
    9494                          no_of_output_plugs_t nrOfOutputPlugs, 
    95                           bool verbose); 
     95                          int verbose); 
    9696    FunctionBlockSelector( const FunctionBlockSelector& rhs ); 
    9797    virtual ~FunctionBlockSelector(); 
     
    110110                         no_of_input_plugs_t nrOfInputPlugs, 
    111111                         no_of_output_plugs_t nrOfOutputPlugs, 
    112                          bool verbose); 
     112                         int verbose); 
    113113    FunctionBlockFeature( const FunctionBlockFeature& rhs ); 
    114114    virtual ~FunctionBlockFeature(); 
     
    127127                                no_of_input_plugs_t nrOfInputPlugs, 
    128128                                no_of_output_plugs_t nrOfOutputPlugs, 
    129                                 bool verbose ); 
     129                                int verbose ); 
    130130    FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs ); 
    131131    virtual ~FunctionBlockEnhancedMixer(); 
     
    144144                             no_of_input_plugs_t nrOfInputPlugs, 
    145145                             no_of_output_plugs_t nrOfOutputPlugs, 
    146                              bool verbose ); 
     146                             int verbose ); 
    147147    FunctionBlockProcessing( const FunctionBlockProcessing& rhs ); 
    148148    virtual ~FunctionBlockProcessing(); 
     
    161161                       no_of_input_plugs_t nrOfInputPlugs, 
    162162                       no_of_output_plugs_t nrOfOutputPlugs, 
    163                        bool verbose); 
     163                       int verbose); 
    164164    FunctionBlockCodec( const FunctionBlockCodec& rhs ); 
    165165    virtual ~FunctionBlockCodec(); 
  • branches/libfreebob-2.0/src/debugmodule/debugmodule.h

    r336 r341  
    126126 */ 
    127127 
    128 #define DO_PREEMPTION_CHECKING 
     128// #define DO_PREEMPTION_CHECKING 
    129129 
    130130#include <sys/time.h> 
     
    132132#ifdef DO_PREEMPTION_CHECKING 
    133133#define CHECK_PREEMPTION(onoff) \ 
    134         gettimeofday (1, (onoff)
     134        gettimeofday((struct timeval *)1, (struct timezone *)onoff
    135135#else 
    136 #define CHECK_PREEMPTION(engine, onoff) 
     136#define CHECK_PREEMPTION(onoff) 
    137137#endif 
    138138 
  • branches/libfreebob-2.0/src/devicemanager.cpp

    r336 r341  
    9090DeviceManager::discover( int verboseLevel ) 
    9191{ 
    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 ); 
    9895 
    9996    for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
  • branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp

    r309 r341  
    3232#include <netinet/in.h> 
    3333#include <assert.h> 
    34  
     34#include <unistd.h> 
    3535 
    3636#include <iostream> 
     
    127127        raw1394_set_bus_reset_handler(m_handle, busreset_handler); 
    128128 
     129    // update the cycle counter value for initial value 
     130    updateCycleCounter(); 
     131 
    129132        return true; 
    130133} 
     
    145148#define CSR_REGISTER_BASE  0xfffff0000000ULL 
    146149 
     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 
    147157unsigned int IsoHandler::getCycleCounter() { 
     158     return m_cyclecounter; 
     159} 
     160 
     161void IsoHandler::updateCycleCounter() { 
    148162    quadlet_t buf=0; 
    149163     
     
    153167    raw1394_read(m_handle_util, raw1394_get_local_id(m_handle_util),  
    154168        CSR_REGISTER_BASE | CSR_CYCLE_TIME, 4, &buf); 
    155          
    156     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Current timestamp: %08X = %u\n",buf, ntohl(buf)); 
    157169     
    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); 
    159181} 
    160182 
  • branches/libfreebob-2.0/src/libstreaming/IsoHandler.h

    r309 r341  
    111111                virtual bool prepare() = 0; 
    112112                 
     113                // get the most recent cycle counter value 
     114                // RT safe 
    113115                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(); 
    114121 
    115122        protected: 
     
    120127                unsigned int    m_max_packet_size; 
    121128                int             m_irq_interval; 
     129                unsigned int    m_cyclecounter; 
    122130 
    123131                int m_packetcount; 
  • branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp

    r309 r341  
    5757} 
    5858 
    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 !!! 
    8061bool IsoHandlerManager::Execute() 
     62{ 
     63    updateCycleCounters(); 
     64    return true; 
     65} 
     66 
     67bool IsoHandlerManager::iterate() 
    8168{ 
    8269        int err; 
     
    8471        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 
    8572         
    86         unsigned long tstamp=debugGetCurrentUTime(); 
    87  
    8873        err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout); 
    89          
    90 //      debugOutput(DEBUG_LEVEL_VERBOSE, "Poll took: %6d\n", debugGetCurrentUTime()-tstamp); 
    9174         
    9275        if (err == -1) { 
     
    11194                        assert(s); 
    11295                         
    113                         unsigned int packetcount_prev=s->getPacketCount(); 
    114                          
    115                         tstamp=debugGetCurrentUTime(); 
    116                          
    11796                        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 
     105void 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    } 
    125114} 
    126115 
  • branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.h

    r250 r341  
    9393 
    9494        protected: 
     95         
     96             
    9597                // RunnableInterface interface 
    9698                bool Execute(); // note that this is called in we while(running) loop 
    9799                bool Init(); 
    98100 
    99  
     101            // iterate all handlers 
     102            bool iterate(); 
     103         
     104        // updates the cycle counter caches of all handlers 
     105        void updateCycleCounters(); 
     106         
    100107                // note: there is a disctinction between streams and handlers 
    101108                // because one handler can serve multiple streams (in case of  
  • branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp

    r312 r341  
    150150        debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    151151 
    152         // and the tread that runs the runner 
    153         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); 
    154154        if(!m_streamingThread) { 
    155155                debugFatal("Could not create streaming thread\n"); 
     
    166166        m_isoManager->setVerboseLevel(getDebugLevel()); 
    167167         
    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"); 
    170173                return false; 
    171174        } 
     
    225228    bool xrun_has_occured=false; 
    226229        bool this_period_ready; 
    227          
    228         unsigned long tstamp_enter=debugGetCurrentTSC(); 
    229          
     230 
    230231//      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"); 
    234235                return false; 
    235236        } 
    236237         
    237         unsigned long tstamp_iso=debugGetCurrentTSC(); 
    238          
    239238        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " RCV PROC: "); 
    240239        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     
    266265        } 
    267266        debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE, "\n"); 
    268          
    269         unsigned long tstamp_periodcheck=debugGetCurrentTSC(); 
    270267 
    271268        if(xrun_has_occured) { 
     
    275272                m_xrun_happened=true; 
    276273                sem_post(&m_period_semaphore); 
     274         
    277275                return false; // stop thread 
    278276        } 
     
    300298                m_nbperiods++; 
    301299        } 
    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_periodcheck 
    307 //         ); 
    308300 
    309301        return true; 
     
    364356        m_streamingThread->Start(); 
    365357         
     358        // start the runner thread 
     359        m_isoManagerThread->Start(); 
     360                 
    366361        debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to start running...\n"); 
    367362        // we have to wait until all streamprocessors indicate that they are running 
     
    425420                } 
    426421 
    427               (*it)->reset(); 
     422              (*it)->reset(); 
    428423 
    429424                if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) { 
     
    441436                } 
    442437                 
    443               (*it)->reset(); 
     438              (*it)->reset(); 
    444439                 
    445440                if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) { 
     
    503498 
    504499 
    505         debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping thread...\n"); 
     500        debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping threads...\n"); 
    506501         
    507502        m_streamingThread->Stop(); 
     503        m_isoManagerThread->Stop(); 
    508504         
    509505        debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handlers...\n"); 
  • branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.h

    r250 r341  
    124124 
    125125        FreebobUtil::PosixThread *m_streamingThread; 
     126        FreebobUtil::PosixThread *m_isoManagerThread; 
    126127 
    127128    unsigned int m_nbperiods;