Changeset 654

Show
Ignore:
Timestamp:
10/17/07 16:04:08 (15 years ago)
Author:
f.ernoult
Message:

MotU: - Rewrite the ports declaration (easier to maintain for new devices)

  • Make MainOut? the defaults ports for the 828mkII
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r639 r654  
    5454    {FW_VENDORID_MOTU, 0, 0x00000003, 0x000001f2, MOTUFW_MODEL_828mkII, "MOTU", "828MkII"}, 
    5555    {FW_VENDORID_MOTU, 0, 0x00000009, 0x000001f2, MOTUFW_MODEL_TRAVELER, "MOTU", "Traveler"}, 
     56}; 
     57 
     58// Ports declarations 
     59const PortEntry Ports_828MKII[] = 
     60{ 
     61    {"Main-L", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 40}, 
     62    {"Main-R", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 43}, 
     63    {"Mix-L", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 10}, 
     64    {"Mix-R", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 13}, 
     65    {"Analog1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 16}, 
     66    {"Analog2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 19}, 
     67    {"Analog3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 22}, 
     68    {"Analog4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 25}, 
     69    {"Analog5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 28}, 
     70    {"Analog6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 31}, 
     71    {"Analog7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 34}, 
     72    {"Analog8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 37}, 
     73    {"Phones-L", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 10}, 
     74    {"Phones-R", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 13}, 
     75    {"Mic1", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 40}, 
     76    {"Mic2", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 43}, 
     77    {"SPDIF1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 46}, 
     78    {"SPDIF2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 49}, 
     79    {"ADAT1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ADAT, 52}, 
     80    {"ADAT2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ADAT, 55}, 
     81    {"ADAT3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ADAT, 58}, 
     82    {"ADAT4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ADAT, 61}, 
     83    {"ADAT5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 63}, 
     84    {"ADAT6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 66}, 
     85    {"ADAT7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 69}, 
     86    {"ADAT8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 72}, 
     87}; 
     88 
     89const PortEntry Ports_TRAVELER[] =  
     90{ 
     91    {"Mix-L", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 10}, 
     92    {"Mix-R", MOTUFW_DIR_IN, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 13}, 
     93    {"Phones-L", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 10}, 
     94    {"Phones-R", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 13}, 
     95    {"Analog1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 16}, 
     96    {"Analog2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 19}, 
     97    {"Analog3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 22}, 
     98    {"Analog4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 25}, 
     99    {"Analog5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 28}, 
     100    {"Analog6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 31}, 
     101    {"Analog7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 34}, 
     102    {"Analog8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 37}, 
     103    {"AES/EBU-L", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ANY, 40}, 
     104    {"AES/EBU-R", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ANY, 43}, 
     105    {"SPDIF1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ANY, 46}, 
     106    {"SPDIF2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ANY, 49}, 
     107    {"ADAT1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ADAT, 52}, 
     108    {"ADAT2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ADAT, 55}, 
     109    {"ADAT3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ADAT, 58}, 
     110    {"ADAT4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_2x|MOTUFW_PA_OPTICAL_ADAT, 61}, 
     111    {"ADAT5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 63}, 
     112    {"ADAT6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 66}, 
     113    {"ADAT7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 69}, 
     114    {"ADAT8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x|MOTUFW_PA_OPTICAL_ADAT, 72}, 
     115}; 
     116 
     117const DevicePortsEntry DevicesPorts[] = { 
     118    { Ports_828MKII, sizeof( Ports_828MKII ) }, 
     119    { Ports_TRAVELER, sizeof( Ports_TRAVELER ) }, 
    56120}; 
    57121 
     
    684748} 
    685749 
    686 signed int MotuDevice::getEventSize(unsigned int dir) { 
     750signed int MotuDevice::getEventSize(unsigned int direction) { 
    687751// 
    688752// Return the size in bytes of a single event sent to (dir==MOTUFW_OUT) or 
     
    694758// need a setFrameRate() for that. 
    695759// 
    696 // At the very least an event consists of the SPH (4 bytes), the control/MIDI 
    697 // bytes (6 bytes) and 8 analog audio channels (each 3 bytes long).  Note that 
    698 // all audio channels are sent using 3 bytes. 
     760// At the very least an event consists of the SPH (4 bytes) and the control/MIDI 
     761// bytes (6 bytes). 
     762// Note that all audio channels are sent using 3 bytes. 
    699763signed int sample_rate = getSamplingFrequency(); 
    700 signed int optical_mode = getOpticalMode(dir); 
    701 signed int size = 4+6+8*3; 
    702  
    703         // 2 channels of AES/EBU is present if a 1x or 2x sample rate is in 
    704         // use 
    705         if (sample_rate <= 96000) 
    706                 size += 2*3; 
    707  
    708         // 2 channels of (coax) SPDIF is present for 1x or 2x sample rates so 
    709         // long as the optical mode is not TOSLINK.  If the optical mode is 
    710         // TOSLINK the coax SPDIF channels are replaced by optical TOSLINK 
    711         // channels.  Thus between these options we always have an addition 
    712         // 2 channels here for 1x or 2x sample rates regardless of the optical 
    713         // mode. 
    714         if (sample_rate <= 96000) 
    715                 size += 2*3; 
    716  
    717         // ADAT channels 1-4 are present for 1x or 2x sample rates so long 
    718         // as the optical mode is ADAT. 
    719         if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) 
    720                 size += 4*3; 
    721  
    722         // ADAT channels 5-8 are present for 1x sample rates so long as the 
    723         // optical mode is ADAT. 
    724         if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) 
    725                 size += 4*3; 
    726  
    727     // When 1x or 2x sample rate is active there are an additional 
    728     // 2 channels sent in an event.  For capture it is a Mix1 return, 
    729     // while for playback it is a separate headphone mix. 
    730     if (sample_rate<=96000) 
    731         size += 2*3; 
    732  
    733         // Finally round size up to the next quadlet boundary 
    734         return ((size+3)/4)*4; 
     764signed int optical_mode = getOpticalMode(direction); 
     765signed int size = 4+6; 
     766 
     767unsigned int i; 
     768unsigned int dir = direction==Streaming::Port::E_Capture?MOTUFW_DIR_IN:MOTUFW_DIR_OUT; 
     769unsigned int flags = (1 << ( optical_mode + 4 )); 
     770 
     771    if ( sample_rate > 96000 ) 
     772        flags |= MOTUFW_PA_RATE_4x; 
     773    else if ( sample_rate > 48000 ) 
     774        flags |= MOTUFW_PA_RATE_2x; 
     775    else 
     776        flags |= MOTUFW_PA_RATE_1x; 
     777 
     778    for (i=0; i < ( DevicesPorts[m_motu_model].PortsListLength /sizeof( PortEntry ) ); i++) { 
     779        if (( DevicesPorts[m_motu_model].PortsList[i].port_dir & dir ) && 
     780           ( DevicesPorts[m_motu_model].PortsList[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
     781           ( DevicesPorts[m_motu_model].PortsList[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
     782            size += 3; 
     783        } 
     784    } 
     785 
     786    // Finally round size up to the next quadlet boundary 
     787    return ((size+3)/4)*4; 
    735788} 
    736789/* ======================================================================= */ 
     
    778831 */ 
    779832const char *mode_str = direction==Streaming::Port::E_Capture?"cap":"pbk"; 
    780 const char *aux_str = direction==Streaming::Port::E_Capture?"Mix1":"Phones"; 
    781833Streaming::StreamProcessor *s_processor; 
    782 unsigned int i, ofs
     834unsigned int i
    783835char *buff; 
     836unsigned int dir = direction==Streaming::Port::E_Capture?MOTUFW_DIR_IN:MOTUFW_DIR_OUT; 
     837unsigned int flags = (1 << ( optical_mode + 4 )); 
     838 
     839    if ( sample_rate > 96000 ) 
     840        flags |= MOTUFW_PA_RATE_4x; 
     841    else if ( sample_rate > 48000 ) 
     842        flags |= MOTUFW_PA_RATE_2x; 
     843    else 
     844        flags |= MOTUFW_PA_RATE_1x; 
    784845 
    785846    // retrieve the ID 
     
    794855        s_processor = m_transmitProcessor; 
    795856    } 
    796     // Offset into an event's data of the first audio data 
    797     ofs = 10; 
    798  
    799     // Add ports for the Mix1 return / Phones send which is present for 
    800     // 1x and 2x sampling rates. 
    801     if (sample_rate<=96000) { 
    802         for (i=0; i<2; i++, ofs+=3) { 
    803             asprintf(&buff,"%s_%s_%s-%c", id.c_str(), mode_str, 
    804               aux_str, i==0?'L':'R'); 
    805             if (!addPort(s_processor, buff, direction, ofs, 0)) 
     857 
     858    for (i=0; i < ( DevicesPorts[m_motu_model].PortsListLength /sizeof( PortEntry ) ); i++) { 
     859        if (( DevicesPorts[m_motu_model].PortsList[i].port_dir & dir ) && 
     860           ( DevicesPorts[m_motu_model].PortsList[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
     861           ( DevicesPorts[m_motu_model].PortsList[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
     862            asprintf(&buff,"%s_%s_%s" , id.c_str(), mode_str, 
     863              DevicesPorts[m_motu_model].PortsList[i].port_name); 
     864            if (!addPort(s_processor, buff, direction, DevicesPorts[m_motu_model].PortsList[i].port_offset, 0)) 
    806865                return false; 
    807866        } 
    808867    } 
    809  
    810     // Unconditionally add the 8 analog capture ports since they are 
    811     // always present no matter what the device configuration is. 
    812     for (i=0; i<8; i++, ofs+=3) { 
    813         asprintf(&buff,"%s_%s_Analog%d", id.c_str(), mode_str, i+1); 
    814         if (!addPort(s_processor, buff, direction, ofs, 0)) 
    815             return false; 
    816     } 
    817  
    818     // AES/EBU ports are present for 1x and 2x sampling rates on the 
    819     // Traveler.  On earlier interfaces (for example, 828 MkII) this 
    820     // space was taken up with a separate "main out" send. 
    821     // FIXME: what is in this position of incoming data on an 828 MkII? 
    822     if (sample_rate <= 96000) { 
    823         for (i=0; i<2; i++, ofs+=3) { 
    824             if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
    825                 asprintf(&buff,"%s_%s_AES/EBU%d", id.c_str(), mode_str, i+1); 
    826             } else { 
    827                 if (direction == Streaming::Port::E_Capture) 
    828                     asprintf(&buff,"%s_%s_Mic%d", id.c_str(), mode_str, i+1); 
    829                 else 
    830                     asprintf(&buff,"%s_%s_MainOut-%c", id.c_str(), mode_str, i==0?'L':'R'); 
    831             } 
    832             if (!addPort(s_processor, buff, direction, ofs, 0)) 
    833                 return false; 
    834         } 
    835     } 
    836  
    837     // SPDIF ports are present for 1x and 2x sampling rates so long 
    838     // as the optical mode is not TOSLINK. 
    839     if (sample_rate<=96000 && optical_mode!=MOTUFW_OPTICAL_MODE_TOSLINK) { 
    840         for (i=0; i<2; i++, ofs+=3) { 
    841             asprintf(&buff,"%s_%s_SPDIF%d", id.c_str(), mode_str, i+1); 
    842             if (!addPort(s_processor, buff, direction, ofs, 0)) 
    843                 return false; 
    844         } 
    845     } 
    846  
    847     // TOSLINK ports are present for 1x and 2x sampling rates so long 
    848     // as the optical mode is set to TOSLINK. 
    849     if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_TOSLINK) { 
    850         for (i=0; i<2; i++, ofs+=3) { 
    851             asprintf(&buff,"%s_%s_TOSLINK%d", id.c_str(), mode_str, i+1); 
    852             if (!addPort(s_processor, buff, direction, ofs, 0)) 
    853                 return false; 
    854         } 
    855     } 
    856  
    857     // ADAT ports 1-4 are present for 1x and 2x sampling rates so long 
    858     // as the optical mode is set to ADAT. 
    859     if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 
    860         for (i=0; i<4; i++, ofs+=3) { 
    861             asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 
    862             if (!addPort(s_processor, buff, direction, ofs, 0)) 
    863                 return false; 
    864         } 
    865     } 
    866  
    867     // ADAT ports 5-8 are present for 1x sampling rates so long as the 
    868     // optical mode is set to ADAT. 
    869     if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 
    870         for (i=4; i<8; i++, ofs+=3) { 
    871             asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 
    872             if (!addPort(s_processor, buff, direction, ofs, 0)) 
    873                 return false; 
    874         } 
    875     } 
    876  
     868     
    877869    return true; 
    878870} 
  • trunk/libffado/src/motu/motu_avdevice.h

    r639 r654  
    7070#define MOTUFW_REG_CLKSRC_NAME0        0x0c60 
    7171 
     72/* Port Active Flags (ports declaration) */ 
     73#define MOTUFW_PA_RATE_1x        0x0001    /* 44k1 or 48k */ 
     74#define MOTUFW_PA_RATE_2x        0x0002    /* 88k2 or 96k */ 
     75#define MOTUFW_PA_RATE_4x        0x0004    /* 176k4 or 192k */ 
     76#define MOTUFW_PA_RATE_ANY       (MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_RATE_4x) 
     77#define MOTUFW_PA_RATE_MASK      0x0007 
     78#define MOTUFW_PA_OPTICAL_OFF    0x0010    /* Optical port off */ 
     79#define MOTUFW_PA_OPTICAL_ADAT   0x0020    /* Optical port in ADAT mode */ 
     80#define MOTUFW_PA_OPTICAL_SPDIF  0x0040    /* Optical port in SPDIF mode */ 
     81#define MOTUFW_PA_OPTICAL_ON     (MOTUFW_PA_OPTICAL_ADAT|MOTUFW_PA_OPTICAL_SPDIF) 
     82#define MOTUFW_PA_OPTICAL_ANY    (MOTUFW_PA_OPTICAL_OFF|MOTUFW_PA_OPTICAL_ON) 
     83#define MOTUFW_PA_OPTICAL_MASK   0x0070 
     84 
    7285class ConfigRom; 
    7386class Ieee1394Service; 
     
    89102    char *vendor_name; 
    90103    char *model_name; 
     104}; 
     105 
     106struct PortEntry { 
     107    char *port_name; 
     108    unsigned int port_dir; 
     109    unsigned int port_flags; 
     110    unsigned int port_offset; 
     111}; 
     112 
     113struct DevicePortsEntry { 
     114    const PortEntry* PortsList; 
     115    int PortsListLength; 
     116    // Others features can be added here like MIDI port presence. 
    91117}; 
    92118