Changeset 487

Show
Ignore:
Timestamp:
06/26/07 14:28:31 (17 years ago)
Author:
wagi
Message:

implementation of getConfigurationId added (rough/raw version)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r479 r487  
    816816AvDevice::getConfigurationId() 
    817817{ 
    818     return 0; 
     818    // create a unique configuration id. 
     819    // this implementation should do the trick but it is done in a very 
     820    // rough way. some cleanup and improvements have to be done for the 
     821    // 'final' version. 
     822 
     823    int id = 0; 
     824    // get sample rate 
     825    { 
     826        ExtendedStreamFormatCmd extStreamFormatCmd( *m_p1394Service ); 
     827        UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 
     828                                         m_nodeId ); 
     829        extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 
     830                                                        PlugAddress::ePAM_Unit, 
     831                                                        unitPlugAddress ) ); 
     832 
     833        extStreamFormatCmd.setNodeId( m_nodeId ); 
     834        extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 
     835        extStreamFormatCmd.setVerbose( true ); 
     836 
     837        if ( !extStreamFormatCmd.fire() ) { 
     838            debugError( "getConfigurationId: stream format command failed\n" ); 
     839            return false; 
     840        } 
     841 
     842        FormatInformation* formatInfo = 
     843            extStreamFormatCmd.getFormatInformation(); 
     844        FormatInformationStreamsCompound* compoundStream 
     845            = dynamic_cast< FormatInformationStreamsCompound* > ( 
     846                formatInfo->m_streams ); 
     847        if ( compoundStream ) { 
     848            //debugOutput( DEBUG_LEVEL_VERBOSE, 
     849            printf("getConfigurationId: sampling frequency %d\n", 
     850                   compoundStream->m_samplingFrequency ); 
     851            id |= compoundStream->m_samplingFrequency; 
     852        } 
     853    } 
     854 
     855    // get number of channels input plug 
     856    // 
     857    // in theory we don't need this information. sample rate + sync mode should 
     858    // ge enough. though to be on the safe side let's us this information as well. 
     859    // yeah and the number of channels for the output plug should also be added. 
     860    { 
     861        ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service ); 
     862        UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 
     863                                         m_nodeId ); 
     864        extPlugInfoCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 
     865                                                    PlugAddress::ePAM_Unit, 
     866                                                    unitPlugAddress ) ); 
     867        extPlugInfoCmd.setNodeId( m_nodeId ); 
     868        extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
     869        extPlugInfoCmd.setVerbose( true ); 
     870        ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 
     871            ExtendedPlugInfoInfoType::eIT_NoOfChannels ); 
     872        extendedPlugInfoInfoType.initialize(); 
     873        extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
     874 
     875        if ( !extPlugInfoCmd.fire() ) { 
     876            debugError( "getConfigurationId: number of channels command failed\n" ); 
     877            return false; 
     878        } 
     879 
     880        ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 
     881        if ( infoType 
     882             && infoType->m_plugNrOfChns ) 
     883        { 
     884            printf( "getConfigurationId: number of channels %d\n", 
     885                    infoType->m_plugNrOfChns->m_nrOfChannels  ); 
     886            id |= infoType->m_plugNrOfChns->m_nrOfChannels << 8; 
     887        } 
     888    } 
     889 
     890    // sync mode: get plug id/type of signal source for sync plug 
     891    { 
     892        SignalSourceCmd signalSourceCmd( *m_p1394Service ); 
     893        SignalUnitAddress signalUnitAddr; 
     894        signalUnitAddr.m_plugId = 0x01; 
     895        signalSourceCmd.setSignalDestination( signalUnitAddr ); 
     896        signalSourceCmd.setNodeId( m_nodeId ); 
     897        signalSourceCmd.setSubunitType( AVCCommand::eST_Unit  ); 
     898        signalSourceCmd.setSubunitId( 0xff ); 
     899 
     900        signalSourceCmd.setCommandType( AVCCommand::eCT_Status ); 
     901 
     902        if ( !signalSourceCmd.fire() ) { 
     903            debugError( "getConfigurationId: number of channels command failed\n" ); 
     904            return false; 
     905        } 
     906 
     907        SignalAddress* pSyncPlugSignalAddress = signalSourceCmd.getSignalSource(); 
     908        SignalUnitAddress* pSyncPlugUnitAddress 
     909            = dynamic_cast<SignalUnitAddress*>( pSyncPlugSignalAddress ); 
     910        if ( pSyncPlugUnitAddress ) { 
     911            printf( "getConfigurationId: sync plug (unit) 0x%04x\n", 
     912                    pSyncPlugUnitAddress->m_plugId ); 
     913        } 
     914 
     915        SignalSubunitAddress* pSyncPlugSubunitAddress 
     916            = dynamic_cast<SignalSubunitAddress*>( pSyncPlugSignalAddress ); 
     917        if ( pSyncPlugSubunitAddress ) { 
     918            printf( "getConfigurationId: sync plug 0x%04x\n", 
     919                    ( pSyncPlugSubunitAddress->m_subunitType << 3 
     920                      | pSyncPlugSubunitAddress->m_subunitId ) << 8 
     921                    | pSyncPlugSubunitAddress->m_plugId ); 
     922 
     923            id |= ( ( pSyncPlugSubunitAddress->m_subunitType << 3 
     924                    | pSyncPlugSubunitAddress->m_subunitId ) << 8 
     925                    | pSyncPlugSubunitAddress->m_plugId ) << 16; 
     926        } 
     927    } 
     928 
     929    return id; 
    819930} 
    820931