Show
Ignore:
Timestamp:
02/27/07 03:31:33 (17 years ago)
Author:
pieterpalmers
Message:

- The library can now be started in 'slave mode', creating a BounceSlaveDevice?.

On a discovering node, this slave device is discovered as a BounceDevice?.
Streaming does not work yet, something wrong with the timestamps.

- Implemented the 'snoop mode', that allows a client to 'snoop' the streams

between another host and a device. It is only implemented for BeBoB devices.
The channel numbers and stream configuration are automatically detected.
Note that it currently relies on a rather hackish support for reading the
{i,o}PCR plugs by using private functions of libiec61883

- changed jack backend to support these two new features

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/src/bounce/bounce_avdevice.cpp

    r420 r424  
    4545static VendorModelEntry supportedDeviceList[] = 
    4646{ 
    47     {0x0B0001, 0x0B0001, 0x0B0001, "FreeBoB", "Bounce"}, 
     47    {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FreeBoB", "Bounce"}, 
    4848}; 
    4949 
     
    5858    , m_p1394Service( &ieee1394service ) 
    5959    , m_nodeId( nodeId ) 
    60     , m_verboseLevel( verboseLevel ) 
     60//     , m_verboseLevel( verboseLevel ) 
     61    , m_verboseLevel( DEBUG_LEVEL_VERBOSE ) 
    6162    , m_samplerate (44100) 
    6263    , m_model( NULL ) 
     
    8586BounceDevice::probe( ConfigRom& configRom ) 
    8687{ 
     88 
     89    debugOutput( DEBUG_LEVEL_VERBOSE, "probing BounceDevice\n"); 
    8790//     unsigned int vendorId = configRom.getNodeVendorId(); 
    8891    unsigned int modelId = configRom.getModelId(); 
    8992    unsigned int unitSpecifierId = configRom.getUnitSpecifierId(); 
     93    debugOutput( DEBUG_LEVEL_VERBOSE, "modelId = 0x%08X, specid = 0x%08X\n", modelId, unitSpecifierId); 
    9094 
    9195    for ( unsigned int i = 0; 
     
    109113BounceDevice::discover() 
    110114{ 
    111 //      unsigned int resp_len=0; 
    112 //      quadlet_t request[6]; 
    113 //      quadlet_t *resp; 
    114  
     115    debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 
     116                 m_nodeId ); 
     117                  
    115118//     unsigned int vendorId = m_configRom->getNodeVendorId(); 
    116119    unsigned int modelId = m_configRom->getModelId(); 
     
    135138        return true; 
    136139    } 
    137      
    138     debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering...\n" ); 
    139  
    140         std::string vendor=std::string(FREEBOB_BOUNCE_SERVER_VENDORNAME); 
    141         std::string model=std::string(FREEBOB_BOUNCE_SERVER_MODELNAME); 
    142  
    143         if (!(m_configRom->getVendorName().compare(0,vendor.length(),vendor,0,vendor.length())==0) 
    144             || !(m_configRom->getModelName().compare(0,model.length(),model,0,model.length())==0)) { 
    145                 return false; 
    146         } 
    147 /* 
    148 // AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT 
    149         request[0] = htonl( AVC1394_CTYPE_STATUS | (AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER << 19) | (0 << 16) 
    150                         | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | 0x00); 
    151  
    152         request[1] =  0xFFFFFFFF; 
    153         resp = m_p1394Service->transactionBlock( m_nodeId, 
    154                                                        request, 
    155                                                        2, 
    156                                                                &resp_len ); 
    157 //      hexDump((unsigned char *)request,6*4); 
    158         if(resp) { 
    159                 char *buffer=(char *)&resp[1]; 
    160                 resp[resp_len-1]=0; 
    161                 xmlDescription=buffer; 
    162 //              hexDump((unsigned char *)resp,6*4); 
    163         } 
    164 */ 
    165         return true; 
     140    return false; 
    166141} 
    167142 
     
    212187    debugOutput(DEBUG_LEVEL_NORMAL, "Node              :  %d\n", m_nodeId); 
    213188    debugOutput(DEBUG_LEVEL_NORMAL, "GUID              :  0x%016llX\n", m_configRom->getGuid()); 
    214     debugOutput(DEBUG_LEVEL_NORMAL, "AVC test response :  %s\n", xmlDescription.c_str()); 
    215189    debugOutput(DEBUG_LEVEL_NORMAL, "\n" ); 
    216190} 
     
    434408        // write value of ISO_CHANNEL register 
    435409        reg_isoch=isochannel; 
    436         if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 
     410        if(!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, reg_isoch)) { 
    437411            debugError("Could not write ISO_CHANNEL register\n"); 
    438412            p->setChannel(-1); 
     
    451425bool 
    452426BounceDevice::stopStreamByIndex(int i) { 
    453  
    454         return false; 
     427    if (i<(int)m_receiveProcessors.size()) { 
     428        int n=i; 
     429        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
     430        unsigned int isochannel=p->getChannel(); 
     431         
     432        fb_quadlet_t reg_isoch; 
     433        // check value of ISO_CHANNEL register 
     434        if(!readReg(BOUNCE_REGISTER_TX_ISOCHANNEL, &reg_isoch)) { 
     435            debugError("Could not read ISO_CHANNEL register\n"); 
     436            return false; 
     437        } 
     438        if(reg_isoch != isochannel) { 
     439            debugError("ISO_CHANNEL register != 0x%08X (=0x%08X)\n", isochannel, reg_isoch); 
     440            return false; 
     441        } 
     442         
     443        // write value of ISO_CHANNEL register 
     444        reg_isoch=0xFFFFFFFFUL; 
     445        if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 
     446            debugError("Could not write ISO_CHANNEL register" ); 
     447            return false; 
     448        } 
     449         
     450        // deallocate ISO channel 
     451        if(!deallocateIsoChannel(isochannel)) { 
     452            debugError("Could not deallocate iso channel for SP\n",i); 
     453            return false; 
     454        } 
     455         
     456        p->setChannel(-1); 
     457        return true; 
     458         
     459    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
     460        int n=i-m_receiveProcessors.size(); 
     461        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
     462         
     463        unsigned int isochannel=p->getChannel(); 
     464         
     465        fb_quadlet_t reg_isoch; 
     466        // check value of ISO_CHANNEL register 
     467        if(!readReg(BOUNCE_REGISTER_RX_ISOCHANNEL, &reg_isoch)) { 
     468            debugError("Could not read ISO_CHANNEL register\n"); 
     469            return false; 
     470        } 
     471        if(reg_isoch != isochannel) { 
     472            debugError("ISO_CHANNEL register != 0x%08X (=0x%08X)\n", isochannel, reg_isoch); 
     473            return false; 
     474        } 
     475         
     476        // write value of ISO_CHANNEL register 
     477        reg_isoch=0xFFFFFFFFUL; 
     478        if(!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, reg_isoch)) { 
     479            debugError("Could not write ISO_CHANNEL register\n"); 
     480            return false; 
     481        } 
     482         
     483        // deallocate ISO channel 
     484        if(!deallocateIsoChannel(isochannel)) { 
     485            debugError("Could not deallocate iso channel for SP (%d)\n",i); 
     486            return false; 
     487        } 
     488         
     489        p->setChannel(-1); 
     490        return true; 
     491    } 
     492     
     493    debugError("SP index %d out of range!\n",i); 
     494    return false; 
    455495} 
    456496 
  • branches/streaming-rework/src/bounce/bounce_avdevice.h

    r420 r424  
    5151// struct to define the supported devices 
    5252struct VendorModelEntry { 
    53     unsigned int vendor_id; 
    54     unsigned int model_id; 
    55     unsigned int unit_specifier_id; 
     53    uint32_t vendor_id; 
     54    uint32_t model_id; 
     55    uint32_t unit_specifier_id; 
    5656    char *vendor_name; 
    5757    char *model_name; 
     
    6969 
    7070    static bool probe( ConfigRom& configRom ); 
    71     virtual bool discover(); 
    72     virtual ConfigRom& getConfigRom() const; 
     71    bool discover(); 
     72    ConfigRom& getConfigRom() const; 
    7373     
    74     virtual bool addXmlDescription( xmlNodePtr deviceNode ); 
     74    bool addXmlDescription( xmlNodePtr deviceNode ); 
    7575     
    76     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    77        virtual int getSamplingFrequency( ); 
     76    bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     77    int getSamplingFrequency( ); 
    7878     
    79        virtual bool prepare(); 
     79    bool prepare(); 
    8080    bool lock(); 
    8181    bool unlock(); 
    82          
    83        virtual int getStreamCount(); 
    84          
    85        virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 
    86          
     82 
     83    int getStreamCount(); 
     84 
     85    Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 
     86 
    8787    bool startStreamByIndex(int i); 
    8888    bool stopStreamByIndex(int i); 
    8989     
    90     virtual void showDevice() const; 
    91     virtual bool setId(unsigned int id); 
     90    void showDevice() const; 
     91    bool setId(unsigned int id); 
    9292 
    9393protected: 
     
    9797    int              m_verboseLevel; 
    9898 
    99 private: 
    10099        std::string xmlDescription; 
    101100 
     
    117116    int allocateIsoChannel(unsigned int packet_size); 
    118117    bool deallocateIsoChannel(int channel); 
    119      
    120 private: // I/O helpers 
     118 
     119protected: // I/O helpers 
    121120    // quadlet read/write routines 
    122121    bool readReg(fb_nodeaddr_t, fb_quadlet_t *); 
  • branches/streaming-rework/src/bounce/bounce_slave_avdevice.cpp

    r422 r424  
    2626 * 
    2727 */ 
    28  
    29 #include "BounceSlaveDevice.h" 
     28#include "libieee1394/configrom.h" 
     29#include "libieee1394/ieee1394service.h" 
     30 
     31#include "bounce_slave_avdevice.h" 
     32#include "libfreebob/freebob_bounce.h" 
     33 
     34#include <libraw1394/raw1394.h> 
     35#include <libavc1394/rom1394.h> 
    3036 
    3137namespace Bounce { 
    3238 
    33 IMPL_DEBUG_MODULE( BounceSlaveDevice, BounceSlaveDevice, DEBUG_LEVEL_NORMAL ); 
    34  
    35 BounceSlaveDevice::BounceSlaveDevice() { 
    36  
     39static VendorModelEntry supportedDeviceList[] = 
     40
     41  //{vendor_id, model_id, unit_specifier_id, vendor_name, model_name}, 
     42    {0x0B0001, 0x0B0001, 0x0B0001, "FreeBoB", "Bounce Slave"}, 
     43}; 
     44 
     45IMPL_DEBUG_MODULE( BounceSlaveDevice, BounceSlaveDevice, DEBUG_LEVEL_VERBOSE ); 
     46 
     47BounceSlaveDevice::BounceSlaveDevice( std::auto_ptr< ConfigRom >( configRom ), 
     48                            Ieee1394Service& ieee1394service, 
     49                            int verboseLevel ) 
     50    : BounceDevice( configRom, 
     51                    ieee1394service, 
     52                    ieee1394service.getLocalNodeId(), 
     53//                     verboseLevel ) 
     54                    DEBUG_LEVEL_VERBOSE ) 
     55
     56    addOption(Util::OptionContainer::Option("isoTimeoutSecs",(int64_t)120)); 
    3757} 
    3858 
     
    4161} 
    4262 
     63bool 
     64BounceSlaveDevice::probe( ConfigRom& configRom ) 
     65{ 
     66    // we are always capable of constructing a slave device 
     67    return true; 
     68} 
     69 
     70bool 
     71BounceSlaveDevice::discover() 
     72{ 
     73    m_model = &(supportedDeviceList[0]); 
     74    if (m_model != NULL) { 
     75        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
     76                m_model->vendor_name, m_model->model_name); 
     77        return true; 
     78    } 
     79    return false; 
     80} 
     81 
     82bool BounceSlaveDevice::initMemSpace() { 
     83    debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing memory space...\n"); 
     84    fb_quadlet_t result=0xFFFFFFFFLU; 
     85     
     86    // initialize the ISO channel registers 
     87    // this will write to our own registers 
     88    if (!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, result)) { 
     89        debugError("Could not initalize ISO channel register for TX\n"); 
     90        return false; 
     91    } 
     92    if (!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, result)) { 
     93        debugError("Could not initalize ISO channel register for TX\n"); 
     94        return false; 
     95    } 
     96     
     97    // set everything such that we can be discovered 
     98    m_original_config_rom=save_config_rom( m_p1394Service->getHandle() ); 
     99     
     100    if ( init_config_rom( m_p1394Service->getHandle() ) < 0 ) { 
     101        debugError("Could not initalize local config rom\n"); 
     102        return false; 
     103    } 
     104     
     105    // refresh our config rom cache 
     106    if ( !m_configRom->initialize() ) { 
     107        // \todo If a PHY on the bus is in power safe mode then 
     108        // the config rom is missing. So this might be just 
     109        // such this case and we can safely skip it. But it might 
     110        // be there is a real software problem on our side. 
     111        // This should be handled more carefuly. 
     112        debugError( "Could not reread config rom from device (node id %d).\n", 
     113                     m_nodeId ); 
     114        return false; 
     115    } 
     116    return true; 
     117} 
     118 
     119bool BounceSlaveDevice::restoreMemSpace() { 
     120    debugOutput(DEBUG_LEVEL_VERBOSE, "Restoring memory space...\n"); 
     121    restore_config_rom( m_p1394Service->getHandle(), m_original_config_rom); 
     122    return true; 
     123} 
     124 
     125bool 
     126BounceSlaveDevice::lock() { 
     127    debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n",  
     128        m_model->vendor_name, m_model->model_name, m_nodeId); 
     129     
     130    // get a notifier to handle device notifications 
     131    nodeaddr_t notify_address; 
     132    notify_address = m_p1394Service->findFreeARMBlock( 
     133                        BOUNCE_REGISTER_BASE, 
     134                        BOUNCE_REGISTER_LENGTH, 
     135                        BOUNCE_REGISTER_LENGTH); 
     136     
     137    if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 
     138        debugError("Could not find free ARM block for notification\n"); 
     139        return false; 
     140    } 
     141     
     142    m_Notifier=new BounceSlaveDevice::BounceSlaveNotifier(this, notify_address); 
     143     
     144    if(!m_Notifier) { 
     145        debugError("Could not allocate notifier\n"); 
     146        return false; 
     147    } 
     148     
     149    if (!m_p1394Service->registerARMHandler(m_Notifier)) { 
     150        debugError("Could not register notifier\n"); 
     151        delete m_Notifier; 
     152        m_Notifier=NULL; 
     153        return false; 
     154    } 
     155     
     156    // (re)initialize the memory space 
     157    if (!initMemSpace()) { 
     158        debugError("Could not initialize memory space\n"); 
     159        return false; 
     160    } 
     161     
     162    return true; 
     163} 
     164 
     165bool 
     166BounceSlaveDevice::unlock() { 
     167    // (re)initialize the memory space 
     168    if (!restoreMemSpace()) { 
     169        debugError("Could not restore memory space\n"); 
     170        return false; 
     171    } 
     172    m_p1394Service->unregisterARMHandler(m_Notifier); 
     173    delete m_Notifier; 
     174    m_Notifier=NULL; 
     175 
     176    return true; 
     177} 
     178 
     179bool 
     180BounceSlaveDevice::prepare() { 
     181    // snooping does not make sense for a slave device 
     182    setOption("snoopMode", false); 
     183     
     184    // prepare the base class 
     185    // FIXME: when doing proper discovery this won't work anymore 
     186    //        as it relies on a completely symmetric transmit/receive 
     187    if(!BounceDevice::prepare()) { 
     188        debugError("Base class preparation failed\n"); 
     189        return false; 
     190    } 
     191     
     192    // do any customisations here 
     193     
     194    return true; 
     195} 
     196 
     197// this has to wait until the ISO channel numbers are written 
     198bool 
     199BounceSlaveDevice::startStreamByIndex(int i) { 
     200     
     201    if (i<(int)m_receiveProcessors.size()) { 
     202        int n=i; 
     203        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
     204         
     205        // the other side sends on this channel 
     206        nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_RX_ISOCHANNEL; 
     207        iso_channel_offset += ((unsigned)n)*4; 
     208         
     209        if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFFLU)) { 
     210            debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 
     211            return false; 
     212        } 
     213         
     214        fb_quadlet_t result; 
     215        // this will read from our own registers 
     216        if (!readReg(iso_channel_offset, &result)) { 
     217            debugError("Could not read ISO channel register for stream %d\n",i); 
     218            return false; 
     219        } 
     220         
     221        // set ISO channel 
     222        p->setChannel(result); 
     223 
     224        return true; 
     225         
     226    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
     227        int n=i-m_receiveProcessors.size(); 
     228        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
     229         
     230        // the other side sends on this channel 
     231        nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_TX_ISOCHANNEL; 
     232        iso_channel_offset += ((unsigned)n)*4; 
     233         
     234        if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFF)) { 
     235            debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 
     236            return false; 
     237        } 
     238         
     239        fb_quadlet_t result; 
     240        // this will read from our own registers 
     241        if (!readReg(iso_channel_offset, &result)) { 
     242            debugError("Could not read ISO channel register for stream %d\n",i); 
     243            return false; 
     244        } 
     245         
     246        // set ISO channel 
     247        p->setChannel(result); 
     248 
     249        return true; 
     250 
     251    } 
     252     
     253    debugError("SP index %d out of range!\n",i); 
     254     
     255    return false; 
     256} 
     257 
     258bool 
     259BounceSlaveDevice::stopStreamByIndex(int i) { 
     260    // nothing special to do I guess... 
     261    return false; 
     262} 
     263 
     264// helpers 
     265bool 
     266BounceSlaveDevice::waitForRegisterNotEqualTo(nodeaddr_t offset, fb_quadlet_t v) { 
     267    debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for StreamProcessor streams to start running...\n"); 
     268    // we have to wait until all streamprocessors indicate that they are running 
     269    // i.e. that there is actually some data stream flowing 
     270    int timeoutSecs=120; 
     271    if(!getOption("isoTimeoutSecs", timeoutSecs)) { 
     272        debugWarning("Could not retrieve isoTimeoutSecs parameter, defauling to 120secs\n"); 
     273    } 
     274     
     275    int wait_cycles=timeoutSecs*10; // two seconds 
     276     
     277    fb_quadlet_t reg=v; 
     278     
     279    while ((v == reg) && wait_cycles) { 
     280        wait_cycles--; 
     281        if (!readReg(offset,&reg)) { 
     282            debugError("Could not read register\n"); 
     283            return false; 
     284        } 
     285        usleep(100000); 
     286    } 
     287 
     288    if(!wait_cycles) { // timout has occurred 
     289        return false; 
     290    } 
     291     
     292    return true; 
     293} 
     294 
     295// configrom helpers 
     296// FIXME: should be changed into a better framework 
     297 
     298 
     299struct BounceSlaveDevice::configrom_backup  
     300BounceSlaveDevice::save_config_rom(raw1394handle_t handle) 
     301{ 
     302    int retval; 
     303    struct configrom_backup tmp; 
     304    /* get the current rom image */ 
     305    retval=raw1394_get_config_rom(handle, tmp.rom, 0x100, &tmp.rom_size, &tmp.rom_version); 
     306//      tmp.rom_size=rom1394_get_size(tmp.rom); 
     307//     printf("save_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,tmp.rom_size,tmp.rom_version); 
     308 
     309    return tmp; 
     310} 
     311 
     312int  
     313BounceSlaveDevice::restore_config_rom(raw1394handle_t handle, struct BounceSlaveDevice::configrom_backup old) 
     314{ 
     315    int retval; 
     316//     int i; 
     317     
     318    quadlet_t current_rom[0x100]; 
     319    size_t current_rom_size; 
     320    unsigned char current_rom_version; 
     321 
     322    retval=raw1394_get_config_rom(handle, current_rom, 0x100, &current_rom_size, &current_rom_version); 
     323//     printf("restore_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,current_rom_size,current_rom_version); 
     324 
     325//     printf("restore_config_rom restoring to romsize %d, rom_version %d:\n",old.rom_size,old.rom_version); 
     326 
     327    retval = raw1394_update_config_rom(handle, old.rom, old.rom_size, current_rom_version); 
     328//     printf("restore_config_rom update_config_rom returned %d\n",retval); 
     329 
     330    /* get the current rom image */ 
     331    retval=raw1394_get_config_rom(handle, current_rom, 0x100, &current_rom_size, &current_rom_version); 
     332    current_rom_size = rom1394_get_size(current_rom); 
     333//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,current_rom_size,current_rom_version); 
     334//     for (i = 0; i < current_rom_size; i++) 
     335//     { 
     336//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
     337//         printf(" %08x", ntohl(current_rom[i])); 
     338//     } 
     339//     printf("\n"); 
     340 
     341    return retval; 
     342} 
     343 
     344int  
     345BounceSlaveDevice::init_config_rom(raw1394handle_t handle) 
     346{ 
     347    int retval, i; 
     348    quadlet_t rom[0x100]; 
     349    size_t rom_size; 
     350    unsigned char rom_version; 
     351    rom1394_directory dir; 
     352    char *leaf; 
     353     
     354    /* get the current rom image */ 
     355    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 
     356    rom_size = rom1394_get_size(rom); 
     357//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); 
     358//     for (i = 0; i < rom_size; i++) 
     359//     { 
     360//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
     361//         printf(" %08x", ntohl(rom[i])); 
     362//     } 
     363//     printf("\n"); 
     364     
     365    /* get the local directory */ 
     366    rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir); 
     367     
     368    /* change the vendor description for kicks */ 
     369    i = strlen(dir.textual_leafs[0]); 
     370    strncpy(dir.textual_leafs[0], FREEBOB_BOUNCE_SERVER_VENDORNAME "                                          ", i); 
     371     
     372    dir.vendor_id=FREEBOB_BOUNCE_SERVER_VENDORID; 
     373    dir.model_id=FREEBOB_BOUNCE_SERVER_MODELID; 
     374     
     375    /* update the rom */ 
     376    retval = rom1394_set_directory(rom, &dir); 
     377//     printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size); 
     378//     for (i = 0; i < rom_size; i++) 
     379//     { 
     380//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
     381//         printf(" %08x", ntohl(rom[i])); 
     382//     } 
     383//     printf("\n"); 
     384     
     385    /* free the allocated mem for the textual leaves */ 
     386    rom1394_free_directory( &dir); 
     387     
     388    /* add an AV/C unit directory */ 
     389    dir.unit_spec_id    = FREEBOB_BOUNCE_SERVER_SPECID; 
     390    dir.unit_sw_version = 0x00010001; 
     391    leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; 
     392    dir.nr_textual_leafs = 1; 
     393    dir.textual_leafs = &leaf; 
     394     
     395    /* manipulate the rom */ 
     396    retval = rom1394_add_unit( rom, &dir); 
     397     
     398    /* get the computed size of the rom image */ 
     399    rom_size = rom1394_get_size(rom); 
     400     
     401//     printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size); 
     402//     for (i = 0; i < rom_size; i++) 
     403//     { 
     404//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
     405//         printf(" %08x", ntohl(rom[i])); 
     406//     } 
     407//     printf("\n"); 
     408//      
     409    /* convert computed rom size from quadlets to bytes before update */ 
     410    rom_size *= sizeof(quadlet_t); 
     411    retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); 
     412//     printf("update_config_rom returned %d\n",retval); 
     413     
     414    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 
     415//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); 
     416//     for (i = 0; i < rom_size; i++) 
     417//     { 
     418//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
     419//         printf(" %08x", ntohl(rom[i])); 
     420//     } 
     421//     printf("\n"); 
     422     
     423//      printf("You need to reload your ieee1394 modules to reset the rom.\n"); 
     424     
     425    return 0; 
     426} 
     427 
     428 
     429// the notifier 
     430 
     431BounceSlaveDevice::BounceSlaveNotifier::BounceSlaveNotifier(BounceSlaveDevice *d, nodeaddr_t start) 
     432 : ARMHandler(start, BOUNCE_REGISTER_LENGTH,  
     433              RAW1394_ARM_READ | RAW1394_ARM_WRITE, // allowed operations 
     434              0, //RAW1394_ARM_READ | RAW1394_ARM_WRITE, // operations to be notified of 
     435              0)                                    // operations that are replied to by us (instead of kernel) 
     436 , m_bounceslavedevice(d) 
     437{ 
     438 
     439} 
     440 
     441BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier()  
     442{ 
     443 
     444} 
     445 
    43446} // end of namespace Bounce 
  • branches/streaming-rework/src/bounce/bounce_slave_avdevice.h

    r422 r424  
    2929#define __FREEBOB_BOUNCESLAVEDEVICE__ 
    3030 
    31 #include "../debugmodule/debugmodule.h" 
     31#include "debugmodule/debugmodule.h" 
     32#include "bounce_avdevice.h" 
    3233 
    3334namespace Bounce { 
    3435 
    35 class BounceSlaveDevice
    36  
     36class BounceSlaveDevice : public BounceDevice
     37    class BounceSlaveNotifier; 
    3738public: 
    3839 
    39         BounceSlaveDevice(); 
    40         virtual ~BounceSlaveDevice(); 
     40    BounceSlaveDevice( std::auto_ptr<ConfigRom>( configRom ), 
     41          Ieee1394Service& ieee1394Service, 
     42          int verboseLevel ); 
     43    virtual ~BounceSlaveDevice(); 
     44     
     45    static bool probe( ConfigRom& configRom ); 
     46    bool discover(); 
     47    bool prepare(); 
     48    bool lock(); 
     49    bool unlock(); 
     50     
     51    bool startStreamByIndex(int i); 
     52    bool stopStreamByIndex(int i); 
     53     
    4154 
    4255protected: 
    4356    DECLARE_DEBUG_MODULE; 
     57private: 
     58    bool waitForRegisterNotEqualTo(nodeaddr_t offset, fb_quadlet_t v); 
     59    bool initMemSpace(); 
     60    bool restoreMemSpace(); 
     61     
     62private: // configrom shit 
    4463 
     64    struct configrom_backup { 
     65        quadlet_t rom[0x100]; 
     66        size_t rom_size; 
     67        unsigned char rom_version; 
     68    }; 
     69    struct configrom_backup m_original_config_rom; 
     70     
     71    struct configrom_backup  
     72        save_config_rom(raw1394handle_t handle); 
     73    int restore_config_rom(raw1394handle_t handle, struct configrom_backup old); 
     74    int init_config_rom(raw1394handle_t handle); 
     75     
     76private: 
     77    BounceSlaveNotifier *m_Notifier; 
     78    /** 
     79     * this class reacts on the ohter side writing to the  
     80     * hosts address space 
     81     */ 
     82    class BounceSlaveNotifier : public ARMHandler 
     83    { 
     84    public: 
     85        BounceSlaveNotifier(BounceSlaveDevice *, nodeaddr_t start); 
     86        virtual ~BounceSlaveNotifier(); 
     87         
     88    private: 
     89        BounceSlaveDevice *m_bounceslavedevice; 
     90    }; 
    4591}; 
    4692