Show
Ignore:
Timestamp:
08/22/07 10:15:34 (17 years ago)
Author:
ppalmers
Message:

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libavc/avc_definitions.cpp

    r445 r554  
    2323 
    2424#include "avc_definitions.h" 
    25  
     25#include <libiec61883/iec61883.h> 
     26 
     27namespace AVC { 
    2628 
    2729int 
     
    151153    return stream << str; 
    152154}; 
     155 
     156enum ESubunitType byteToSubunitType(byte_t s) { 
     157    switch (s) { 
     158    case eST_Monitor: 
     159        return eST_Monitor; 
     160    case eST_Audio: 
     161        return eST_Audio; 
     162    case eST_Printer: 
     163        return eST_Printer; 
     164    case eST_Disc: 
     165        return eST_Disc; 
     166    case eST_VCR: 
     167        return eST_VCR; 
     168    case eST_Tuner: 
     169        return eST_Tuner; 
     170    case eST_CA: 
     171        return eST_CA; 
     172    case eST_Camera: 
     173        return eST_Camera; 
     174    case eST_Panel: 
     175        return eST_Panel; 
     176    case eST_BulltinBoard: 
     177        return eST_BulltinBoard; 
     178    case eST_CameraStorage: 
     179        return eST_CameraStorage; 
     180    case eST_Music: 
     181        return eST_Music; 
     182    case eST_VendorUnique: 
     183        return eST_VendorUnique; 
     184    case eST_Reserved: 
     185        return eST_Reserved; 
     186    case eST_Extended: 
     187        return eST_Extended; 
     188    default: 
     189    case eST_Unit: 
     190        return eST_Unit; 
     191    } 
     192} 
     193 
     194unsigned int fdfSfcToSampleRate(byte_t fdf) { 
     195    switch(fdf & 0x07) { 
     196        default:                       return 0; 
     197        case IEC61883_FDF_SFC_32KHZ:   return 32000; 
     198        case IEC61883_FDF_SFC_44K1HZ:  return 44100; 
     199        case IEC61883_FDF_SFC_48KHZ:   return 48000; 
     200        case IEC61883_FDF_SFC_88K2HZ:  return 88200; 
     201        case IEC61883_FDF_SFC_96KHZ:   return 96000; 
     202        case IEC61883_FDF_SFC_176K4HZ: return 176400; 
     203        case IEC61883_FDF_SFC_192KHZ:  return 192000; 
     204    } 
     205} 
     206 
     207byte_t sampleRateToFdfSfc(unsigned int rate) { 
     208    switch(rate) { 
     209        default:      return 0x07; 
     210        case 32000:   return IEC61883_FDF_SFC_32KHZ; 
     211        case 44100:   return IEC61883_FDF_SFC_44K1HZ; 
     212        case 48000:   return IEC61883_FDF_SFC_48KHZ; 
     213        case 88200:   return IEC61883_FDF_SFC_88K2HZ; 
     214        case 96000:   return IEC61883_FDF_SFC_96KHZ; 
     215        case 176400:  return IEC61883_FDF_SFC_176K4HZ; 
     216        case 192000:  return IEC61883_FDF_SFC_192KHZ; 
     217    } 
     218} 
     219 
     220} 
  • trunk/libffado/src/libavc/avc_definitions.h

    r445 r554  
    2222 */ 
    2323 
    24 #ifndef AVDDEFINITIONS_H 
    25 #define AVDDEFINITIONS_H 
     24#ifndef AVCDEFINITIONS_H 
     25#define AVCDEFINITIONS_H 
    2626 
    2727#include <libavc1394/avc1394.h> 
    2828#include <ostream> 
     29 
     30 
     31namespace AVC { 
    2932 
    3033typedef byte_t ctype_t; 
     
    8386typedef quadlet_t company_id_t; 
    8487 
     88#define AVC1394_SUBUNIT_AUDIO 1 
     89#define AVC1394_SUBUNIT_PRINTER 2 
     90#define AVC1394_SUBUNIT_CA 6 
     91#define AVC1394_SUBUNIT_PANEL 9 
     92#define AVC1394_SUBUNIT_BULLETIN_BOARD 0xA 
     93#define AVC1394_SUBUNIT_CAMERA_STORAGE 0xB 
     94#define AVC1394_SUBUNIT_MUSIC 0xC 
     95#define AVC1394_SUBUNIT_RESERVED 0x1D 
     96 
     97#define AVC1394_SUBUNIT_ID_RESERVED 0x06 
     98 
     99enum ESubunitType { 
     100    eST_Monitor       = AVC1394_SUBUNIT_VIDEO_MONITOR, 
     101    eST_Audio         = AVC1394_SUBUNIT_AUDIO, 
     102    eST_Printer       = AVC1394_SUBUNIT_PRINTER, 
     103    eST_Disc          = AVC1394_SUBUNIT_DISC_RECORDER, 
     104    eST_VCR           = AVC1394_SUBUNIT_VCR, 
     105    eST_Tuner         = AVC1394_SUBUNIT_TUNER, 
     106    eST_CA            = AVC1394_SUBUNIT_CA, 
     107    eST_Camera        = AVC1394_SUBUNIT_VIDEO_CAMERA, 
     108    eST_Panel         = AVC1394_SUBUNIT_PANEL, 
     109    eST_BulltinBoard  = AVC1394_SUBUNIT_BULLETIN_BOARD, 
     110    eST_CameraStorage = AVC1394_SUBUNIT_CAMERA_STORAGE, 
     111    eST_Music         = AVC1394_SUBUNIT_MUSIC, 
     112    eST_VendorUnique  = AVC1394_SUBUNIT_VENDOR_UNIQUE, 
     113    eST_Reserved      = AVC1394_SUBUNIT_RESERVED, 
     114    eST_Extended      = AVC1394_SUBUNIT_EXTENDED, 
     115    eST_Unit          = AVC1394_SUBUNIT_UNIT, 
     116}; 
     117 
     118enum ESubunitType byteToSubunitType(byte_t s); 
     119 
    85120/** 
    86121 * \brief the possible sampling frequencies 
     
    118153std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency ); 
    119154 
    120 #define AVC1394_SUBUNIT_AUDIO 1 
    121 #define AVC1394_SUBUNIT_PRINTER 2 
    122 #define AVC1394_SUBUNIT_CA 6 
    123 #define AVC1394_SUBUNIT_PANEL 9 
    124 #define AVC1394_SUBUNIT_BULLETIN_BOARD 0xA 
    125 #define AVC1394_SUBUNIT_CAMERA_STORAGE 0xB 
    126 #define AVC1394_SUBUNIT_MUSIC 0xC 
    127 #define AVC1394_SUBUNIT_RESERVED 0x1D 
     155/** 
     156 * \brief Convert from a FDF SFC field value to an integer sample rate 
     157 * @param fdf fdf sfc field value 
     158 * @return sample rate 
     159 */ 
     160unsigned int fdfSfcToSampleRate(byte_t fdf); 
    128161 
    129 #define AVC1394_SUBUNIT_ID_RESERVED 0x06 
     162/** 
     163 * \brief Convert from an integer sample rate to a78 FDF SFC field value 
     164 * @param rate integer sample rate 
     165 * @return fdf sfc field value 
     166 */ 
     167byte_t sampleRateToFdfSfc(unsigned int rate); 
    130168 
    131 #endif // AVDDEFINITIONS_H 
     169
     170 
     171#endif // AVCDEFINITIONS_H 
  • trunk/libffado/src/libavc/general/avc_plug.cpp

    r548 r554  
    16631663    // FIXME: The derived class should be creating these, such that discover() can become pure virtual 
    16641664 
     1665    if ( !deser.isExisting( basePath + "m_subunitType" ) ) { 
     1666        return 0; 
     1667    } 
    16651668    Plug* pPlug = new Plug; 
    16661669    if ( !pPlug ) { 
     
    22212224                               Unit& unit ) 
    22222225{ 
     2226    if ( !deser.isExisting( basePath + "m_srcPlug" ) ) { 
     2227        return 0; 
     2228    } 
    22232229    PlugConnection* pConnection = new PlugConnection; 
    22242230    if ( !pConnection ) { 
  • trunk/libffado/src/libavc/general/avc_subunit.cpp

    r524 r554  
    242242    bool result; 
    243243    ESubunitType sbType; 
     244 
     245    if ( !deser.isExisting( basePath + "m_sbType" ) ) { 
     246        return 0; 
     247    } 
     248 
    244249    result  = deser.read( basePath + "m_sbType", sbType ); 
    245250 
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r548 r554  
    603603    } 
    604604 
    605     PlugVector digitalPCRInputPlugs = getPlugsByType( m_externalPlugs, 
     605    PlugVector digitalExternalInputPlugs = getPlugsByType( m_externalPlugs, 
    606606                                                    Plug::eAPD_Input, 
    607607                                                    Plug::eAPT_Digital ); 
     608    if ( !digitalExternalInputPlugs.size() ) { 
     609        debugOutput( DEBUG_LEVEL_VERBOSE, "No external digital input plugs found\n" ); 
     610 
     611    } 
     612     
     613    PlugVector syncExternalInputPlugs = getPlugsByType( m_externalPlugs, 
     614                                                    Plug::eAPD_Input, 
     615                                                    Plug::eAPT_Sync ); 
     616    if ( !syncExternalInputPlugs.size() ) { 
     617        debugOutput( DEBUG_LEVEL_VERBOSE, "No external sync input plugs found\n" ); 
     618 
     619    } 
    608620 
    609621    PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 
     
    639651    debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 
    640652    showPlugs( isoPCROutputPlugs ); 
    641     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR digital Input Plugs:\n" ); 
    642     showPlugs( digitalPCRInputPlugs ); 
     653    debugOutput( DEBUG_LEVEL_VERBOSE, "External digital Input Plugs:\n" ); 
     654    showPlugs( digitalExternalInputPlugs ); 
     655    debugOutput( DEBUG_LEVEL_VERBOSE, "External sync Input Plugs:\n" ); 
     656    showPlugs( syncExternalInputPlugs ); 
    643657    debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 
    644658    showPlugs( syncMSUInputPlugs ); 
     
    670684                                      "Internal (CSP)" ); 
    671685 
    672     // Check all external PCR digital input to MSU input connections 
     686    // Check all external digital input to MSU input connections 
    673687    // -> SPDIF/ADAT sync 
    674     checkSyncConnectionsAndAddToList( digitalPCRInputPlugs, 
     688    checkSyncConnectionsAndAddToList( digitalExternalInputPlugs, 
     689                                      syncMSUInputPlugs, 
     690                                      "Digital Input Sync" ); 
     691 
     692    // Check all external sync input to MSU input connections 
     693    // -> SPDIF/ADAT sync 
     694    checkSyncConnectionsAndAddToList( syncExternalInputPlugs, 
    675695                                      syncMSUInputPlugs, 
    676696                                      "Digital Input Sync" ); 
     
    835855Unit::deserializeSyncInfoVector( Glib::ustring basePath, 
    836856                                     Util::IODeserialize& deser, 
    837                                      Unit& unit, 
    838857                                     SyncInfoVector& vec ) 
    839858{ 
     
    849868        Glib::ustring description; 
    850869 
    851         result  = deser.read( strstrm.str() + "m_source", sourceId ); 
    852         result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
    853         result &= deser.read( strstrm.str() + "m_description", description ); 
     870        if ( deser.isExisting( strstrm.str() + "m_source" ) ) { 
     871            result  = deser.read( strstrm.str() + "m_source", sourceId ); 
     872            result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
     873            result &= deser.read( strstrm.str() + "m_description", description ); 
     874        } else { 
     875            result = false; 
     876        } 
    854877 
    855878        if ( result ) { 
    856879            SyncInfo syncInfo; 
    857             syncInfo.m_source = unit.getPlugManager().getPlug( sourceId ); 
    858             syncInfo.m_destination = unit.getPlugManager().getPlug( destinationId ); 
     880            syncInfo.m_source = m_pPlugManager->getPlug( sourceId ); 
     881            syncInfo.m_destination = m_pPlugManager->getPlug( destinationId ); 
    859882            syncInfo.m_description = description; 
    860883 
     
    895918    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    896919    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    897     result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
     920#warning this fails after the echoaudio merge 
     921//     result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
    898922     
    899923    int i = 0; 
     
    915939bool 
    916940Unit::deserialize( Glib::ustring basePath, 
    917                    Unit* pDev, 
    918941                   Util::IODeserialize& deser, 
    919942                   Ieee1394Service& ieee1394Service ) 
     
    925948    setDebugLevel( verboseLevel ); 
    926949     
    927     if (pDev->m_pPlugManager) delete pDev->m_pPlugManager; 
    928     pDev->m_pPlugManager = PlugManager::deserialize( basePath + "Plug", deser, *pDev ); 
    929     if ( !pDev->m_pPlugManager ) { 
     950    if (m_pPlugManager) delete m_pPlugManager; 
     951    m_pPlugManager = PlugManager::deserialize( basePath + "Plug", deser, *this ); 
     952    if ( !m_pPlugManager ) { 
    930953        return false; 
    931954    } 
    932955     
    933     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, pDev->m_pcrPlugs ); 
    934     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, pDev->m_externalPlugs ); 
    935     result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 
    936     result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *pDev, pDev->m_subunits ); 
    937     result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, *pDev, pDev->m_syncInfos ); 
     956    result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_pcrPlugs ); 
     957    result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_externalPlugs ); 
     958    result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 
     959    result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *this, m_subunits ); 
     960    result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 
     961 
    938962 
    939963    unsigned int i; 
     
    941965 
    942966    if ( result ) { 
    943         if ( i < pDev->m_syncInfos.size() ) { 
    944             pDev->m_activeSyncInfo = &pDev->m_syncInfos[i]; 
     967        if ( i < m_syncInfos.size() ) { 
     968            m_activeSyncInfo = &m_syncInfos[i]; 
    945969        } 
    946970    } 
  • trunk/libffado/src/libavc/general/avc_unit.h

    r548 r554  
    9494 
    9595    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    96     static bool deserialize( Glib::ustring basePath, Unit*
     96    bool deserialize( Glib::ustring basePath
    9797                                 Util::IODeserialize& deser, 
    9898                                 Ieee1394Service& ieee1394Service ); 
     
    151151 
    152152 
    153     static bool serializeSyncInfoVector( Glib::ustring basePath, 
     153    bool serializeSyncInfoVector( Glib::ustring basePath, 
    154154                                         Util::IOSerialize& ser, 
    155155                                         const SyncInfoVector& vec ); 
    156     static bool deserializeSyncInfoVector( Glib::ustring basePath, 
     156    bool deserializeSyncInfoVector( Glib::ustring basePath, 
    157157                                           Util::IODeserialize& deser, 
    158                                            Unit& avDevice, 
    159158                                           SyncInfoVector& vec ); 
    160159protected: