Changeset 1923

Show
Ignore:
Timestamp:
11/20/10 02:52:54 (13 years ago)
Author:
jwoithe
Message:

MOTU: 828mk1: update optical port mode control based on more recent dumps provided by Martin Peach. These changes are yet to be tested with an 828mk1.

Files:

Legend:

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

    r1921 r1923  
    17771777    // 
    17781778    // If a mode parameter pointer is NULL it will not be returned. 
    1779     unsigned int reg
     1779    unsigned int reg, reg2
    17801780    unsigned int mask, shift; 
    17811781 
     
    17871787    if (m_motu_model == MOTU_MODEL_828MkI) { 
    17881788        // The early devices used a different register layout.   
     1789        unsigned int mask2; 
    17891790        reg = ReadRegister(MOTU_G1_REG_CONFIG); 
    1790         mask = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_MASK:MOTU_G1_OPT_OUT_MODE_MASK; 
    1791         shift = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_BIT0:MOTU_G1_OPT_OUT_MODE_BIT0; 
    1792         switch ((reg & mask) >> shift) { 
    1793             case MOTU_G1_OPTICAL_OFF: *port_a_mode = MOTU_OPTICAL_MODE_OFF; break; 
    1794             case MOTU_G1_OPTICAL_TOSLINK: *port_a_mode = MOTU_OPTICAL_MODE_TOSLINK; break; 
    1795             // MOTU_G1_OPTICAL_OFF and MOTU_G1_OPTICAL_ADAT seem to be 
    1796             // identical, so currently we don't know how to differentiate 
    1797             // these two modes. 
    1798             // case MOTU_G1_OPTICAL_ADAT: return MOTU_OPTICAL_MODE_ADAT; 
     1791        reg2 = ReadRegister(MOTU_G1_REG_CONFIG_2); 
     1792 
     1793        mask = (dir==MOTU_DIR_IN)?MOTU_G1_C1_OPT_TOSLINK_IN:MOTU_G1_C1_OPT_TOSLINK_OUT; 
     1794        mask2 = (dir==MOTU_DIR_IN)?MOTU_G1_C2_OPT_nADAT_IN:MOTU_G1_C2_OPT_nADAT_OUT; 
     1795 
     1796        if ((reg & mask) && (reg2 & mask2)) { 
     1797          /* Toslink bit set, nADAT bit set -> Toslink mode */ 
     1798          *port_a_mode = MOTU_OPTICAL_MODE_TOSLINK; 
     1799        } else 
     1800        if ((reg & mask)==0 && (reg2 & mask2)==0) { 
     1801          /* Toslink bit clear, nADAT bit clear -> ADAT mode */ 
     1802          *port_a_mode = MOTU_OPTICAL_MODE_ADAT; 
     1803        } else { 
     1804          /* All other combinations are unexpected except toslink clear/ 
     1805           * nADAT set, so just assume the optical port is off if we get 
     1806           * here. 
     1807           */ 
     1808          *port_a_mode = MOTU_OPTICAL_MODE_OFF; 
    17991809        } 
    18001810        return 0; 
     
    18691879    if (m_motu_model == MOTU_MODEL_828MkI) { 
    18701880        // The earlier MOTUs handle this differently. 
    1871         unsigned int mask, shift, g1mode = 0; 
    1872         reg = ReadRegister(MOTU_G1_REG_CONFIG); 
    1873         mask = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_MASK:MOTU_G1_OPT_OUT_MODE_MASK; 
    1874         shift = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_BIT0:MOTU_G1_OPT_OUT_MODE_BIT0; 
    1875         switch (port_a_mode) { 
    1876             case MOTU_OPTICAL_MODE_OFF: g1mode = MOTU_G1_OPTICAL_OFF; break; 
    1877             case MOTU_OPTICAL_MODE_ADAT: g1mode = MOTU_G1_OPTICAL_ADAT; break; 
    1878             // See comment in getOpticalMode() about mode ambiguity 
    1879             // case MOTU_OPTICAL_MODE_TOSLINK: g1mode = MOTU_G1_OPTICAL_TOSLINK; break; 
    1880         } 
    1881         reg = (reg & ~mask) | (g1mode << shift); 
    1882         return WriteRegister(MOTU_G1_REG_CONFIG, reg); 
     1881        unsigned int g1_conf1, g1_conf2; 
     1882        unsigned int toslink, n_adat; 
     1883        g1_conf1 = ReadRegister(MOTU_G1_REG_CONFIG); 
     1884        g1_conf2 = ReadRegister(MOTU_G1_REG_CONFIG_2); 
     1885        toslink = (dir==MOTU_DIR_IN)?MOTU_G1_C1_OPT_TOSLINK_IN:MOTU_G1_C1_OPT_TOSLINK_OUT; 
     1886        n_adat = (dir==MOTU_DIR_IN)?MOTU_G1_C2_OPT_nADAT_IN:MOTU_G1_C2_OPT_nADAT_OUT; 
     1887 
     1888        /* Set registers as needed by the requested mode */ 
     1889        g1_conf1 &= ~toslink; 
     1890        g1_conf2 |= n_adat; 
     1891        if (port_a_mode == MOTU_OPTICAL_MODE_TOSLINK) { 
     1892          g1_conf1 |= toslink; 
     1893        } else { 
     1894          g1_conf1 &= ~toslink; 
     1895        } 
     1896        if (port_a_mode == MOTU_OPTICAL_MODE_ADAT) { 
     1897          g1_conf2 &= ~n_adat; 
     1898        } else { 
     1899          g1_conf2 |= n_adat; 
     1900        } 
     1901        if (WriteRegister(MOTU_G1_REG_CONFIG, g1_conf1)!=0 || 
     1902            WriteRegister(MOTU_G1_REG_CONFIG_2, g1_conf2)!=0) 
     1903            return -1; 
     1904        return 0; 
    18831905    } 
    18841906 
  • trunk/libffado/src/motu/motu_avdevice.h

    r1916 r1923  
    101101/* Device register definitions for the earliest generation devices */ 
    102102#define MOTU_G1_REG_CONFIG         0x0b00 
    103 #define MOTU_G1_REG_ISOCTRL        0x0b10 
     103#define MOTU_G1_REG_CONFIG_2       0x0b10 
    104104 
    105105/* Values written to registers in G1 devices. 
    106106 * 
    107  * There's an unknown subtlety regarding the optical mode of the "generation 
    108  * 1" devices such as the 828Mk1.  It seems that the same configuration 
    109  * register setting is used for "off" and "adat" modes.  There must be more 
    110  * to this though because the number of audio channels sent presumedly 
    111  * changes when adat mode is selected; there must be some way that the 
    112  * device deduces the mode. 
    113  */ 
    114 #define MOTU_G1_OPT_IN_MODE_MASK   0x8000 
    115 #define MOTU_G1_OPT_IN_MODE_BIT0       15 
    116 #define MOTU_G1_OPT_OUT_MODE_MASK  0x4000 
    117 #define MOTU_G1_OPT_OUT_MODE_BIT0      14 
    118 #define MOTU_G1_OPTICAL_OFF        0x0000 
    119 #define MOTU_G1_OPTICAL_TOSLINK    0x0001 
    120 #define MOTU_G1_OPTICAL_ADAT       0x0000 
     107 * Control of the optical mode on the G1 devices (such as the 828mk1) is 
     108 * strange in that it's split across two configration registers.  
     109 * Furthermore, while the toslink mode is controlled by "enable" bits, the 
     110 * ADAT mode is controlled by "disable" bits (that is, the mode is active if 
     111 * the bits are clear. 
     112 */ 
     113#define MOTU_G1_C1_OPT_TOSLINK_IN  0x8000 
     114#define MOTU_G1_C1_OPT_TOSLINK_OUT 0x4000 
     115#define MOTU_G1_C2_OPT_nADAT_IN    0x0080 
     116#define MOTU_G1_C2_OPT_nADAT_OUT   0x0040 
    121117 
    122118#define MOTU_G1_RATE_MASK          0x0004